-
Notifications
You must be signed in to change notification settings - Fork 8
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
Extending base methods on base types is bad practice #3
Comments
Thanks for you input! I am aware of this. But this package is specifically designed to be quite "at the bottom" and actually change some of the behaviors of these base methods. No types are defined in FuntionalData, all behavior is meant for base types. |
Could you do one of:
|
One thing I did not mention: Care has been taken to only use type combinations which to not interfere with how the methods are defined in base, eg I define Only in very few cases (like Thanks for your suggestions! (2) is tricky, as the functionality is mostly basic plumbing, and many simple, natural verbs ( I will look into (1), that might be possible. But doesn't this mean tons of name-clash warnings all the time? And (3) is of course always good. |
By (1), do you mean a change from: export map
import Base.map
map(a, f::Function) = ..... to export map
map(a, f::Function) = .....
map(a...) = Base.map(a...) I am just testing this and this does seem to work. Is the differente that in the first case I change the behaviour for all loaded packages and in the second only for the ones that have |
Right. Though exporting it, as in the second case, may result in "both Base and FunctionalData export The macro suggestion would work by having |
I will look into this! Do you have an example / docs link for |
That was just a proposed name, you'd have to implement such a macro by recursively walking the Expr, checking if any |
got it ;-) |
This means other people's totally unrelated code changes behavior depending on whether or not your package is loaded. Generally if a method is imported from Base, you should only add methods to it if at least one of the arguments is of a type defined within this package.
The text was updated successfully, but these errors were encountered: