I object to this wording. You can't have an alias to something that doesn't exist. What is really happening is that, in older Perl, passing a member of an aggregate (an array element or a hash value) forced it to be created so that it could be aliased and the alias put into @_ (because sub call arguments are an lvalue context just like other lvalue context that might not actually change the variable you place in them). In this new Perl, instead a "magic" scalar is created and modifying this magic scalar will cause a new scalar to be inserted into the aggregate (if not already inserted by some other operation) and then cause the modified value to be copied over that member. At no point is this magic placeholder scalar an alias to the potential aggregate member (I bet).
I don't have a bleeding-edge Perl so I can't test, but I can already think of quite a few ways in which this change likely significantly modifies existing behavior (not to mention the ways in which it certainly modifies long-standing behavior). Nothing like throwing in some complex "magic" to break backward compatability and make really explaining lvalue context a lot more complicated for the sake of preventing a minor newbie surprise. And why, again, is it that we can't make <>'s use of @ARGV not be completely stupid? I guess doing so doesn't require enough complicated magic in order to make it appealing to p5p.
At least once in this documentation the term "alias" should be replaced with "magic 'alias'".
- tye
In reply to Re: perlsub question.. ("alias"?!)
by tye
in thread perlsub question..
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |