in reply to Re^2: How will you use state declared variables in Perl6?
in thread How will you use state declared variables in Perl6?
Hmm. I would need to understand the difference between state and local, and the scope on the namespace in which state variables live.
Ie. Does state $foo; refer to the same thing across packages, files, modules, threads?
In single threaded apps, a truely global (process wide) variable type has uses for things like DB handles, file handles, sockets, ports, etc. anything that is a truely process global entity.
Once you introduce threads into the equations, things get sticky. It very much depends upon the threading models supported by the OS and which of those models is used by libraries supplying services to your process as to whether things like DB handles can be safely used across threads or not.
One assumes that the state keyword came into being in order to support a particular scenario. A good description of that scenario, and the implications of would be nice to see.
|
|---|