On Mon, 7 Jan 2013 17:51:52 +0100 Carl Mäsak <[email protected]> wrote:
CM> Ted (>):
>> Are state variables available now, or is the every(N) functionality
>> possible in some other way now?
CM> Why not try it by writing a small program? :)
CM> Rakudo is available at a discount right now -- download it before it's
CM> too late! -- and the syntax for state variables is the same as it's
CM> always been. The one-liner to find out is shorter than your question:
CM> $ perl6 -e 'sub foo { state $s = 0; say $s++ }; foo; foo; foo'
CM> 0
CM> 1
CM> 2
Thank you for the explanation.
Since I'm writing a module, I didn't think a one-liner was sufficient
proof that state variables are reliable. Sorry I didn't make that
clear. I was worried about edge cases, and also wondered if there may
be a better way to implement my proposal--I don't know Perl 6 and Rakudo
well enough. It seems like state variables are best, right now.
Thanks!
Ted