|No such thing as a small change|
Re^6: RFC: Is there more to alias?by xmath (Hermit)
|on Aug 25, 2004 at 00:17 UTC||Need Help??|
You still misundestand how Data::Alias works, and you seem to see too much magic where there is none. Data::Alias does no parsing, perl does the parsing, so all syntax is just perl's syntax. Like I said in the description, "alias" itself is a nop. To perl, it's thin air. In fact, if you look at the operations executed (-MO=Concise,-exec), for example for alias push @x, $y:
See the call to alias? Nope, it isn't even there, apart from a miniscule stub "ex-list" (a nop). Alias just changes the semantics of whatever is inside it, and in a very simple way: whereever perl normally copies data, aliasing occurs instead.
So, let's analyze the cases. Take $x = alias [$y, $z] for example. What does it do? The [$y, $z] is just the array constructor which normally creates a new array, fills it with copies of $y and $z, and returns a reference to the array. Within the scope of "alias", it therefore creates a new array, fills it with aliases to $y and $z, and returns a reference to the array, which it then normally assigned to $x.
alias push @x, $y is indeed as you noted parsed as alias(push(@x, $y)). This push would normally add a copy of $y onto the end of @x, so within "alias" it adds an alias to $y onto the end of @x. This obviously differs from alias $x[-1] = $y which would overwrite the last element of @x with an alias to $y.
You finally mentioned using a comma... ($x, $y) involves no copying, therefore alias($x, $y) does nothing remarkable. It behaves 100% identical to plain ($x, $y).
All cleared up now? :-)
Time for me to get some sleep too.. zZ