-
Notifications
You must be signed in to change notification settings - Fork 0
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
Manual Inclusion in __init__
, an alternative to @postinit
#2
Comments
Initially there was an option to not generate any init. But it's quite complicated to find a supertype's module in some situations. So I'm using init to setup the lookup table for the loaded module based on its To allow manual checking, I'd need to build up a dynamic route map depending on how a set of modules was loaded. |
I could have @postinit mangle the name of the function a bit, so all you'd need to do is prepend @postinit to your existing init with no other changes. But name mangling can create confusion. It's better to explicitly change the name: original code function __init__()
...
end with Inherit.jl using Inherit
@postinit function __myinit__()
...
end Another reason not to mangle is it cannot prevent Inherit.jl's init from being overwritten, if the user manually defines her own init outside of @postinit. |
some other possible solutions if enough people are concerned about clobbering of init
|
Rather than forcing an implementation of
__init__
on the user and having them opt into their own__init__
with@postinit
, could you instead expose a function which has a method implementation for each module, and the user manually include that in their__init__
? This is the approach thatBinaryTraits.jl
takes, reference here.I think this would be much less disruptive to users workflows than having them restructure their existing
__init__
s per package.I really like the idea that this package enforces the presence of fields as part of an interface, that's an issue I've not found a good solution for, and this looks promising. Thanks for the contribution!
The text was updated successfully, but these errors were encountered: