Larry wrote:

Gee, if static var makes a subroutine stateful, maybe it's just:

state $s = 0;

That's very nice, and (unlike C<has>) it's verbose enough.


It would also work well for creating class-private shared state.

And for things like loop counters:

        while @list {
            (state $count = 0)++;
            process(splice @list, 0, rand(@list));
        }
        print "Took $count repetitions to process list\n";


Damian




Reply via email to