develooper Front page | perl.perl6.language | Postings from February 2001

Re: assign to magic name-of-function variable instead of "return"

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
February 7, 2001 15:00
Subject:
Re: assign to magic name-of-function variable instead of "return"
Message ID:
20010207230009.R63724@plum.flirble.org
On Wed, Feb 07, 2001 at 04:30:24PM -0600, David L. Nicol wrote:

> 	sub has_post_blocks{
> 		my $i = 3;
> 		post { print "i ended up as $i"};
> 		my $arg1 = shift; $arg1 > 4 or die "arg1 ($arg1) too small";
> 		my $j = 2;
> 		post { print "j ended up as $j"};
> 		...
> 	};
> 
> might only print the message about i when arg1 is too small.  This would
> allow informational messages to be declared at the beginning, for instance.
> 
> It would be implemented by pushing the post block onto the list of things
> to do at scope exit, at run time.

I quite like this idea.  (I certainly like the ability to say "clean up this
thing at the end of scope whatever exceptions may happen)

But part of me feels it should be a POST block.
Because it's behaving much like CHECK or END

Nicholas Clark

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