adding methods to imported functions should not be the default #1278

Closed
JeffBezanson opened this Issue Sep 13, 2012 · 2 comments

Projects

None yet

2 participants

@JeffBezanson
Member

Currently if a module imports f and then says f(...) = ... it adds a method. This is different from assignments; f = ... will always create a new binding. It could also lead to unexpected behavior since you might unintentionally add a method when you meant to have your own (possibly private!) function. The default should be changed.

One possibility is for the default behavior to be adding f(x...) = Other.f(x...), so the new function falls back to the imported one.

To add a method to an imported function, you have to specify something like extend f.

@JeffBezanson JeffBezanson was assigned Sep 13, 2012
@nolta
Member
nolta commented Oct 23, 2012

I think this may be the same issue:

julia> uppercase("testingß")
"TESTINGß"

julia> load("icu.jl")

julia> uppercase("testingß")
"TESTINGSS"

A new method gets bound to uppercase, even though the module wasn't imported.

@JeffBezanson
Member

Closed by merge of jb/modulechanges branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment