in reply to Re^2: Why not use a local variable for $self in Moose?
in thread Why not use a local variable for $self in Moose?
I don't have a clear idea of how memory gets allocated for a class.
Remember that in Perl, An Object is Simply a Data Structure. Even though Moose may add a ton of functionality, in the end, a Moose object is just a blessed hashref. When you allocate a new anonymous hash with {}, that's newly allocated memory. However, variables defined at the package level belong to that package - they are set up when the package is parsed and executed, which typically happens only once; a new package variable isn't instantiated because you created an instance of a class.
|
|---|