in reply to Re^2: Unusual variable declaration
in thread Unusual variable declaration
What's happening is declaration, allocation and initialization.
You are right that our $var declares a "lexical alias" to $__PACKAGE__:var
But if this is the first use of the package variable it'll also allocate memory and initialize the value at runtime (which is undef if not assigned otherwise)
I.o.W. I doubt that the slot of the typeglob will be populated before, hence I'd call this a full declaration.
I suppose the terminology "declaration" stems from statically typed languages and needs to be properly redefined here.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
I didn't check the implementation details, so the timing between compile and run-time might slightly differ.
|
|---|