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

[perl #114932] state(@a) =

Thread Next
From:
Father Chrysostomos via RT
Date:
October 16, 2012 14:45
Subject:
[perl #114932] state(@a) =
Message ID:
rt-3.6.HEAD-11172-1350423948-1881.114932-14-0@perl.org
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.

Right?

-- 

Father Chrysostomos


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