develooper Front page | perl.perl5.porters | Postings from November 2021

Re: A 'permanent' keyword

Thread Previous | Thread Next
Oodler 577 via perl5-porters
November 11, 2021 18:57
Re: A 'permanent' keyword
Message ID:
* Paul "LeoNerd" Evans <> [2021-11-11 16:59:32 +0000]:

> It's kindof unfortunate that `state` behaves in this manner, as it
> isn't actually very useful.

Having stateful subroutines is helpful in some cases, here is a
trivial example. Obviously YMMV depending on how crazy one gets,
but for a simple FSM it implicitly makes consumer code a lot more

> What you describe is exactly what C calls a `static` variable. Because
> it isn't lexical, nor is it dynamic. It exists exactly once.
> I actually wonder whether the keyword "static" should be used here.

I thought about that, with my very limited C knowledge, if 'static' is
what's actually wanted here. This would not be a terrible concept to

> In any case, it's ~trivial to implement that as a CPAN module as a
> pluggable keyword. So I'd suggest someone go do that first, and we'll
> see how it goes.

Too rich for my blood x) - but yeah I think it'd be neat to see.


> -- 
> Paul "LeoNerd" Evans
>      |
>  |

SDF-EU Public Access UNIX System - #openmp #pdl #native

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About