Think about Loose Coupling | |
PerlMonks |
Re^3: Unusual variable declarationby LanX (Saint) |
on Nov 04, 2019 at 14:44 UTC ( [id://11108300]=note: print w/replies, xml ) | Need Help?? |
Yes and no ... the definitions vary. 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
updateI didn't check the implementation details, so the timing between compile and run-time might slightly differ.
In Section
Seekers of Perl Wisdom
|
|