On Friday, 15 May 2015 15:13:11 UTC+2, Michael Francis wrote: > > @Scott, @Toivo > > In my mind this changing the meaning of existing code is happening all the > time with the verbs in Base. Each time I use a module it can (and likely > does) inject new behavior for verbs defined in Base ( or for verbs defined > in any other module) These silently change the way other modules work. > This is actually the beauty of the type system as it allows a module to add > features to another module without having to fork the module. The only > thing you can't do is add new verbs to an existing module. > > Is that not the case ? > That really depends on how you look at it. You are right, of course, that many packages extend functions in Base, and need to in order to function properly. I will argue, however, that most of these do no change how other code works (and if they do, they shouldn't).
What a package should not do is to overload a function in another module in a way that makes code that does not depend on the package behave differently than before. That is bad style and I believe there is more or less an implicit consensus that you don't do that. (And, by #265 <https://github.com/JuliaLang/julia/issues/265>, it might not do what you want.) If you look at packages that extend functions in other modules, I believe that in pretty much all examples you will find, the added methods involve a type that is defined in the package itself. Thus, they will never affect code that doesn't depend on the package. I seem to remember that there was talk at some point about introducing a limitation that you could not extend a function in another module unless you used a type defined in your own module in the signature, but it was not implemented. I'm still not sure if it captures all relevant cases.
