in reply to Re^4: Unifying namespaces of @name and $name to simplify dereferencing? (declaration of typed references)
in thread Unifying namespaces of @name and $name to simplify dereferencing?
I didn't think to have a block scoped switching of syntax, don't think this would be wise.That's block scoped the same way other pragmas are block scoped, if you want to use them on a whole file that's just fine, but if you want to be able to have a finer control over when the aliasing happens, (because you think the aliasing looks like you break the encapsulation on objects, or one of the two variables has magic that the other bypasses (once again, by magic I mostly mean ties) and you'd rather have a compile time than a run time bug) you should be able to.
or @a should be an alias of @$a and always reflect the list form of wherever $a points.That's not possible, because this means that \@a would not have a constant value for the duration of the program. And you can't magic your way out of it because sometimes only the stringified ref is kept (as the key of a hash).
As for your declaration proposition, I'll say that offering a better safety net is always a good idea. I've been bitten before because I absentmindedly used the wrong brackets for my type, like $var->{3} when really I was thinking about an array the whole time, but for some reason I confused the two, or my finger just went on typing the brackets they were told to use the X previous time in a row. So ++ for compile time types :).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Unifying namespaces of @name and $name to simplify dereferencing? (declaration of typed references)
by LanX (Saint) on Mar 27, 2016 at 20:49 UTC | |
by Eily (Monsignor) on Mar 28, 2016 at 12:17 UTC | |
|
Re^6: Unifying namespaces of @name and $name to simplify dereferencing? (declaration of typed references)
by LanX (Saint) on Mar 27, 2016 at 21:21 UTC | |
by Eily (Monsignor) on Mar 28, 2016 at 12:23 UTC |