Skip to content
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 shadowing #1661

Closed
nolta opened this issue Dec 3, 2012 · 3 comments
Closed

function argument shadowing #1661

nolta opened this issue Dec 3, 2012 · 3 comments

Comments

@nolta
Copy link
Member

nolta commented Dec 3, 2012

This should probably generate a warning:

julia> f(x,x) = 2x

julia> f(1,3)
6
@johnmyleswhite
Copy link
Member

Personally, I think that should be fatal error. So wacky.

@StefanKarpinski
Copy link
Sponsor Member

Although I basically agree, there is one possibly far-reaching consequence of this: we might need to make _ special the way it is in Ruby. The reasoning is that currently _ can be a normal variable and you can binding multiply for things you don't care about like so:

_, x, _ = f()

But if we start warning about shadowed assignments like this, does that become illegal? Anyway, since we allow just omitting argument names, maybe having it be an error just in function signatures is ok.

@JeffBezanson
Copy link
Sponsor Member

Multiple assignment is actually sequential, so that just rebinds _. Function arguments are the only instance of "simultaneous" assignments. Talk about details! Anyway this might as well be an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants