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

local function definitions hide base #1505

Closed
mlubin opened this issue Nov 6, 2012 · 5 comments
Closed

local function definitions hide base #1505

mlubin opened this issue Nov 6, 2012 · 5 comments

Comments

@mlubin
Copy link
Member

mlubin commented Nov 6, 2012

Related to issue #1500.

julia> ref() = 1

julia> y = [1,2,3]
3-element Int64 Array:
 1
 2
 3

julia> y[1]
no method ref(Array{Int64,1},Int64)
 in method_missing at base.jl:72
@staticfloat
Copy link
Sponsor Member

Discussion of this is pretty well summed up in Issue #1484, where the general consensus is to rename ref to something more difficult to collide with.

@mlubin
Copy link
Member Author

mlubin commented Nov 6, 2012

The issue isn't with the name ref. If you want to implement ref (show, length, etc..) for a new type, it will hide the base version. This is a bug.

@nolta
Copy link
Member

nolta commented Nov 6, 2012

This isn't a bug. If you want to extend ref, you have to import Base.ref first.

@staticfloat
Copy link
Sponsor Member

Indeed, sorry about misreading that. This is related to the bug (can't find the issue right now where it was originally reported) where importing names, using them, then overriding them behaves differently then importing names, overriding them and then using them. For instance, the following works:

julia> y = [1,2,3]
3-element Int64 Array:
 1
 2
 3

julia> y[1]
1

julia> ref() = 1

julia> y[1]
1

@mlubin
Copy link
Member Author

mlubin commented Nov 6, 2012

import Base.ref seems to work. I'll close this.

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

3 participants