Re: implementing every(N)
On Mon, 7 Jan 2013 17:51:52 +0100 Carl Mäsak 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
Re: implementing every(N)
On Tue, Jan 08, 2013 at 12:14:22PM -0500, Ted Zlatanov wrote: > On Mon, 7 Jan 2013 17:51:52 +0100 Carl Mäsak 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> $ perl6 -e 'sub foo { state $s = 0; say $s++ }; foo; foo; foo' > > 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. [...] Also, if the state variables currently behave as you expect, and we want to insure their reliability for the future, add a spectest to the "roast" suite. This way we'll also quickly discover if other Perl 6 implementations differ on this point. :-) Thanks! Pm