Acme::Gosub - Implement BASIC-like "gosub" and "greturn" in Perl


Acme-Gosub documentation  | view source Contained in the Acme-Gosub distribution.

Index


NAME

Top

Acme::Gosub - Implement BASIC-like "gosub" and "greturn" in Perl

SYNOPSIS

Top

    use Acme::Gosub;

    sub pythagoras
    {
        my ($x, $y) = (@_);
        my ($temp, $square, $sum);
        $sum = 0;
        $temp = $x;
        gosub SQUARE;
        $sum += $square;
        $temp = $y;
        gosub SQUARE;
        $sum += $square;
        return $sum;

    SQUARE:
        $square = $temp * $temp;
        greturn;
    }

DESCRIPTION

Top

Using this function enables using the "gosub" and "greturn" statements inside your program. "gosub" is identical to "goto" except that it records the place from which it was invoked. Then, when a "greturn" is used, it jumps back to the place of the last goto that was not "greturned" yet. If you're not a BASIC programmer you can think of it as a poor man's recursion.

For more information consult the examples in the test files.

FUNCTIONS

Top

filter()

Does the actual filtering to the code.

filter_blocks()

The workhorse of the module - does most of the work of transforming the code.

line()

Taken from Switch.pm.

unimport()

Cancels the filter.

AUTHOR

Top

Damian Conway is the original author of Switch.pm on which this module is based.

Shlomi Fish ( <shlomif@iglu.org.il> ) converted Switch.pm to become Acme::Gosub.

BUGS

Top

The function's gosub recursion stack is function-wide and so different instances of the function will all use the same recursion stack. Hopefully it will be fixed in later versions.

I am not sure whether this will work on dynamic functions (a.k.a closures).

Please report any bugs or feature requests to bug-acme-gosub@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-Gosub. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top

SEE ALSO

Top

Acme::ComeFrom .


Acme-Gosub documentation  | view source Contained in the Acme-Gosub distribution.