develooper Front page | perl.perl5.porters | Postings from April 2007

Re: Differences between state variables and smart matches in 5.10and 6

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
April 2, 2007 04:59
Subject:
Re: Differences between state variables and smart matches in 5.10and 6
Message ID:
p06230930c2369fbc6edb@[192.168.56.5]
At 11:39 AM +0200 4/2/07, Rafael Garcia-Suarez wrote:
>What we would like to have here is ONCE blocks, actually. But I don't
>see how to do this without a modifiable optree (even with
>indirections).

What are ONCE blocks more than something like:

my %done;
sub ONCE (&) {
     my ( $code ) = @_;

     return if exists $done{$code};

     $code->();
     $done{$code} = undef;
}

my $variable;
ONCE { $variable = $_ } foreach 1..5;
print "variable = $variable\n";
=====================
variable = 1


?  Or do you really want to clean up the optrees as well?



Liz

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