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 must be explicitly imported to be extended #9547

Closed
dpo opened this issue Jan 1, 2015 · 9 comments
Closed

Function must be explicitly imported to be extended #9547

dpo opened this issue Jan 1, 2015 · 9 comments
Assignees
Labels
kind:regression Regression in behavior compared to a previous version

Comments

@dpo
Copy link
Contributor

dpo commented Jan 1, 2015

A discussion over at Docile.jl exposed the following behavior with Julia 0.3 and certain builds of Julia 0.4:

julia> methods(factorize)  # Output omitted
julia> factorize(a, b, c, d, e) = ()
ERROR: error in method definition: function LinAlg.factorize must be explicitly imported to be extended

while other builds of Julia 0.4 give:

julia> methods(factorize)  # Output omitted
julia> factorize(a, b, c, d, e) = ()
factorize (generic function with 8 methods)

It seems like one should be able to define a function with the same name as a function in Base, but which isn't mean to extend it. Or is this behavior intentional somehow?

@ihnorton
Copy link
Member

ihnorton commented Jan 2, 2015

I'm pretty sure this is intentional at this point. See also #2327 #8283.

@JeffBezanson
Copy link
Sponsor Member

The error seems to have gone away. I have no idea how that happened.

@dpo
Copy link
Contributor Author

dpo commented Jan 2, 2015

Are you expecting an error to be raised or not?

@JeffBezanson
Copy link
Sponsor Member

There should be an error.

@JeffBezanson
Copy link
Sponsor Member

My commit a3d637f is at fault.

@JeffBezanson
Copy link
Sponsor Member

Also, to clarify, you can define a new function with the same name as one in Base, but not when that name from Base has already been used to refer to the Base function.

@JeffBezanson JeffBezanson added the kind:regression Regression in behavior compared to a previous version label Jan 2, 2015
@JeffBezanson JeffBezanson self-assigned this Jan 2, 2015
@dpo
Copy link
Contributor Author

dpo commented Jan 2, 2015

That makes a lot of sense. And calling methods() would qualify as referring to the Base function I suppose?!

@JeffBezanson
Copy link
Sponsor Member

It's not the call to methods but the use of the factorize identifier.

@MichaelHatherly
Copy link
Member

Thanks for the clarification Jeff.

kshyatt pushed a commit to kshyatt/julia that referenced this issue Jan 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

4 participants