Haimov, Eugene wrote:

> Bill,
> Thanks for you suggestions.
> Here is the way I though of doing it:
> 
> <snip>
> print "here - before sub\n";
> 
> #---------------------------------
> # replacement for "sub my_sub"
> goto end_my_sub;
> my_sub:
> #---------------------------------
> 
>       print "inside sub\n";
> 
>       goto pop(@STACK);   # replacement for "return"
> #---------------------------------
> # replacement for "}"
> end_my_sub:
> #---------------------------------
> 
> print "after sub\n";
> 
> print "Now calling sub\n";
> 
> 
> #---------------------------------
> # replacement for "my_sub()"
> push ( @STACK, 'ret_here' );
> goto my_sub;
> ret_here:
> #---------------------------------
> 
> print "finished\n";
> </snip>
> 
> This way everything is "flat" from the Perl point of view, and so I
> can pass the control into literally ANY point of the program, as
> long as I have it labeled, and saved that label in the session.
> 
> To work in practive, this approach requires some pre-processing
> to be done on the Perl source. I wonder if Perl has some facility
> to plug-in such custom pre-processor (written in Perl). If not, it 
> will have to be a separate "step" from "source" to "executable".

I don't find goto's to be very structured code.  I would think a
single state vrbl that tells what step to execute would be easier
to follow and easier to implement.

Even with the goto's, you could just verify that the state vrbl
was legit (using a hash) and then just do the goto without all
the rest of the junk.

if (exists $hash{$state}) {
        goto $state;
} else {
        error
}

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to