in reply to Re^3: Accessing Arguments inside Subroutines via @_
in thread Accessing Arguments inside Subroutines via @_
I took a look into the Panther book and experimented with Devel::Peek and the implementation of aliases seems simpler than a magic data structure of type alias.
Arrays (AVs) are composed from C-structures with pointers to C-structure(s) realizing scalars (SVs).
So $_[0]=666 updates the underlying scalar ( what I called "assigning" ) while @_=(666) creates the pointer to a new scalar ( "setting" ).
In the following dump the scalar value for $x is held within SV = IV(0x88f2498) at 0x88f249c
The array's first slot will point to that same structure before and after updating with $_[0]=666 (#markers added)
But creating new entries with @_=(666) will replace the pointer in this AV-slot to a new SV.
I hope the "how" is clearer now! :)
|
---|