develooper Front page | perl.perl5.porters | Postings from October 2012

[perl #114932] state(@a) =

Thread Next
Father Chrysostomos via RT
October 16, 2012 14:45
[perl #114932] state(@a) =
Message ID:
On Sun Sep 16 12:15:05 2012, sprout wrote:
> This hasn’t been implemented yet, and I do not see any existing ticket
> for it.
> (state @a) = ... is not supposed to have the assign-once behaviour.
> state(@a) = ... and state @a = ... are (if Ι understand correctly).

I believe this reasoning makes sense in Perl 5 (even if it is not
exactly the same as the Perl 6 explanation):

It is ‘state’ (with its arguments) that is treated specially on the LHS
of =.  So (state @a)=... is not special-cased, because what is on the
LHS is more than just state.  But state(@a) is special-cased, because
the (@a) bit is part of the state() call.  (Think of state as a function.)

So that means state(our @foo) = ... should assign to the package
variable @foo once.



Father Chrysostomos

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About