Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^5: How will you use state declared variables in Perl6?

by TimToady (Parson)
on Jul 08, 2005 at 23:27 UTC ( [id://473613]=note: print w/replies, xml ) Need Help??


in reply to Re^4: How will you use state declared variables in Perl6?
in thread How will you use state declared variables in Perl6?

If it's illegal, it's because you took the address of a named declaration, not because of the state declarations. But ignoring the "qux" (and the entire question of whether that should be legal) your use of state variables would certainly be legal. The inner $foo hides the outer $foo just as a "my" variable would. And every time you clone the inner closure you'll get a new copy of the inner state variable, and it will initialize itself the first time that clone is called. It implies the existence of some kind of persistent lexical pad, which is a certain amount of work for the implementation, but we really didn't see much benefit in duplicating the functionality of globals, and a lot of benefit in having a kind of "my" that doesn't reinitialize the second time through.
  • Comment on Re^5: How will you use state declared variables in Perl6?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (None)
    As of 2024-04-25 01:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found