-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make is alias
imply is ro
.
#79
Comments
@schwern wrote:
I strenuously disagree. In fact, I think that first implication is
I even more strenuously disagree. "Alias" implies "all the original characteristics". So adding an implicit We spent a lot of time on this when we were designing Perl 6.
So, if you're going to break backwards compatibility, why not break it in favour Except, as you're considering exiling aliases in any case, you probably can't So maybe just reverse your original implication. That is:
Which produces:
"is alias") Damian |
On 4/27/13 10:48 PM, thoughtstream wrote:
I'd totally agree if aliasing in Perl 5 were reliable. I don't think we
In a pass by reference language this would make sense, since every In a pass by copy language like Perl 5, the assumption is if you pass in
Read-write aliases break this assumption and leave the caller unable to
While you can already do that with @_, I don't want to encourage that If a function wants to alter its caller's data I'd rather it said so.
|
Fair enough.
Um. Is that a reasonable assumption. Given that $[0], $[1], etc. in And given that quite a few of Perl's own builtins (open, close, chomp, (Note: not saying it's good; just saying it's so).
Far be it from me to argue with my own prescriptions from PBP. ;-)
True. In which case we should remove "is alias" entirely. But, if we're not going to remove it, we shouldn't mess up its Is the real problem that you're trying to solve here that If so, perhaps we need to fix that instead? Damian |
On 4/28/13 9:25 PM, thoughtstream wrote:
Yes. It's mostly unknown that you can modify @_ and it looks gross. In my experiences cleaning up and refactoring all sorts of code,
They're built ins. They're special in all sorts of ways. They break
Do they? Oh crap, I never even tried it. That's a bug. No, the real problem for me was "is alias" is dangerous and easier to Not sure what I think about "is ro_alias" in that regard. |
Yeah, it's less than ideal. My objection to "is alias" changing To me the point is that a parameter with "is ro is alias" is identical Whereas, when I use "is alias", I do so because I want that specific So that tells me we need another kind of "is ro" to indicate What we have now is:
That indicates a failure of interface to me: of the nine possibilities, In contrast, the Perl 6 interface is:
copy and alias) with one fewer keyword, and only one redundant case. But we can't do that. So here's another bold suggestion... Given your disinclination to promote the use of aliases and your desire
aliases not supported) This is mostly consistent with current use usages[*], has only one Submitted for your consideration. Damian [*] Except, obviously that the default behaviour is no longer |
I strenuously agree with @thoughtstream. :-D A read-only alias is pretty useless. An read-only alias of a scalar is less efficient than a copy, and aliasing of non-scalars doesn't work (and you could, and probably should, use the So, what, exactly, is the use case for a read-only alias? The only time I ever use |
Read-only aliases are a great way to save memory and if you accidentally try to modify the variable Perl will spit at you.
Read-write aliases have far more limited use cases, either you can't be arsed to pass in a reference or you're doing something magical. If you accidentally use a read-write alias Perl won't tell you.
Read-write is the default for aliased variables. Whoops.
is alias
should implyis ro
, same wayis copy
impliesis rw
. If the user wants a modifiable alias they should have to explicitly declare it so, or consider using a copy or pass by reference.This would break backwards compatibility, but I wonder how much code it would actually break, and how many accidental modifications of aliases it would reveal.
The text was updated successfully, but these errors were encountered: