This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make state $zok = slosh(); behave as the Perl 6 design with an implicit
authorNicholas Clark <nick@ccl4.org>
Thu, 6 Sep 2007 09:18:41 +0000 (09:18 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 6 Sep 2007 09:18:41 +0000 (09:18 +0000)
commitc5917253cfa0ec36b4c868a1582baaaab99eb0d0
tree617731b471122ffb901814d1a2cec921fd95e1a9
parent5f0a87760bb9130fbd7579236f81db0729b54496
Make state $zok = slosh(); behave as the Perl 6 design with an implicit
START block. First time through, call slosh() and assign to $zok.
Subsequently neither call slosh() nor assign to $zok. Adds a new op
ONCE to control the conditonal call and assign. No change to list
context, so state ($zok) = slosh() and (state $zok) = ... etc will
still repeatedly evaluate and assign. [Can't fix that before 5.10]
Use as an RVALUE is as Larry's design - my $boff = state $zok = ...;
will evaluate, assign and return first time, and subsequently act as if
it were written my $boff = $zok;
FIXME - state $zok = ...; won't deparse - I believe op->op_last isn't
being correctly set on the sassign, but I don't know how to fix this.
This change may be backed out before 5.10.

p4raw-id: //depot/perl@31798
op.c
opcode.h
opcode.pl
opnames.h
pp.c
pp.sym
pp_proto.h
t/op/state.t