-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Function argument alias #129
base: main
Are you sure you want to change the base?
Conversation
We discussed this on today's sync call. We discussed a lot of different options, but @sylvanc suggested (and @kulibali, @mfelsche, and I agreed) that a good alternative to solve this set of problems is to allow locals to shadow members (fields and methods), with the understanding that members will always be accessible by prefixing with This would make the I mentioned that we'd have to make sure that error messages would try to detect and suggest disambiguation issues when you forget to use @mfelsche mentioned that it would be important to update the tutorial to reflect that change. |
That seems like a good option. The main reason I went with But I think |
Could we restrict the rule mentioned above a bit more and say, that only parameters should be able to shadow members, not I have to admit, having slept a night over it, i still have mixed feelings about it. |
I'm really uneasy about allowing any sort of shadowing. The only real time I have ever felt the pain of this is when using "where = BLAH" in a function calling and not being able to use the name I wanted because it was the same as a public field of the object. I think malthe's idea from my understanding addresses this one pain point. I don't like the idea discussed on the sync call of allowing locals to shadow fields and access via |
I personally prefer an explicit solution (i.e. the proposed RFC) than an implicit one that might lead to refactoring bugs. That said, I am in favour of this RFC, as it'd be helpful specially for named arguments on a constructor, avoiding using primes both on the API and in the actor/class fields. |
I am generally not in favour of this RFC, as I think the use of The only annoyance I've found with Pony's shadowing rules is when I want to have a parameter in a constructor be the same as a getter method. |
I'm in general not in favor of this RFC as currently written. I'm mentioned in the text of the RFC as recommending that primes be optional when invoking with named arguments, and I still believe this, as I agree with @SeanTAllen that this is the biggest problem to solve here. The RFC points out that this wouldn't solve the problem of primes showing up in documentation and such, but I don't really see that as being a big issue. I find the |
This was discussed in depth on today's sync call. We're not in favor of this approach to solving the problem, for the reasons already discussed. There are a few alternatives that we discussed that remain on the table for further discussion:
|
Pony's shadowing prohibition means that using an object field or method name as a function argument is not allowed. This is a proposal to add an optional clause to function arguments that gives the argument a local alias.
Rendered