Shlomi Fish > Acme-Gosub-v0.1.5 > Acme::Gosub

Download:
Acme-Gosub-v0.1.5.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: v0.1.5   Source  

NAME ^

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

SYNOPSIS ^

    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 ^

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 ^

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 ^

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 ^

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 ^

COPYRIGHT & LICENSE ^

Copyright (c) 1997-2003, Damian Conway. All Rights Reserved. Modified by Shlomi Fish, 2005 - all rights disclaimed.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

Acme::ComeFrom .

syntax highlighting: