Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Keep It Simple, Stupid
 
PerlMonks  

Perl 5.9.4 released

by theorbtwo (Prior)
on Sep 04, 2006 at 13:14 UTC ( #571081=perlnews: print w/ replies, xml ) Need Help??

Perl has taken another step on the path to 5.10 with the release of 5.9.4. The most fun new feature, as far as I'm concerned looks to be state variables. Read pod/perl594delta.pod in perl.git for more on that, and other new things since 5.9.3. (There is no release announcement yet, so I'm not linking to it.)

Update: Er, yes, there is a release announcement, and this is apparently old news.

Update: Typo fix, thanks, McDarren


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Comment on Perl 5.9.4 released
Re: Perl 5.9.4 released
by greenFox (Vicar) on Sep 04, 2006 at 14:06 UTC

    re state variables, do I read it correctly that we would no longer have to write:

    { my $stately; sub some_func { # use $stately here } }

    to get a variable which maintains it's state? Neat. Can any-one give us a glimpse of the internals and let us know how that is done? My random guess: turn off garbage collection for state variables?

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

      Kind of. When you say sub foo {my $bar}, perl doesn't actually allocate a new variable every time you execute foo. Instead, it just clears the value. When you say state $bar it doesn't do that either. (This gets into the variable/value split, which is generally not talked about much in perl5-land. Suffice it to say, I did mean to say "variable" and "value" when I did.)


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      The main motivation behind state variables in perl5 land was to get rid of the awful hack:

      my $var if 0;

      Which was a way of getting state variables, but worked on an undocumented side-effect of how lexical pads are implemented. And the code is neater than having to close a an external variable over a routine.

      The main patch (although there were a few tweaks a couple of months later as kinks were ironed out), as landed in the repository, is quite small, all things considered.

      Basically it's just a tweak on lexical variables.

      Another nifty feature of 5.9.4 is that $_ can be made lexical.

      • another intruder with the mooring in the heart of the Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlnews [id://571081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2014-04-18 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (466 votes), past polls