develooper Front page | perl.perl6.internals | Postings from August 2004

Re: Something to ponder

Thread Previous | Thread Next
From:
Dan Sugalski
Date:
August 18, 2004 07:07
Subject:
Re: Something to ponder
Message ID:
a06110402bd49122dba99@[10.0.1.2]
At 6:20 PM -0400 8/17/04, Aaron Sherman wrote:
>On Tue, 2004-08-17 at 16:22, Felix Gallo wrote:
>>  On Tue, Aug 17, 2004 at 04:08:34PM -0400, Dan Sugalski wrote:
>>  > 1) We're going to have MMD for functions soon
>>  > 2) Function invocation and return continuation invocation's
>>  > essentially identical
>>  > 3) Therefore returning from a sub/method can do MMD return based on
>>  > the return values
>
>>  $x -----\
>>           \
>>  @mylist -+--- $obj.mymmdsub;
>>           / 
>>  %hash --/  
>
>How very fungible of you ;-)
>
>Still, I think that's a nice APPLICATION, but the concept is more
>flexible, if I understand it correctly. It would be something that would
>look more like a cross between exception handling and a switch
>statement.
>[snip]
>Is that the kind of thing you had in mind, Dan, or am I misunderstanding
>how return continuations work?

Yep, though the error dispatch case is definitely the easy one. Where 
it gets fun is:

    sub foo :come_from('bar', int) {
      print "In foo!";
    }

    sub baz :come_from('bar', string) {
      print "in Baz!";
    }

    sub bar {
      return(rand() > .5 ? 1 : "Nope");
    }

with that code, half the time it'll print "In foo!", the other half 
"in Baz" when you call bar, because where it goes when bar exits 
depends on what bar returns...
-- 
				Dan

--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About