-
Notifications
You must be signed in to change notification settings - Fork 14
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
@traitfn
on callable types
#86
Comments
As in #87, maybe I should just avoid doing stuff like this, since it will invalidate functions in Base. |
Yes, this is also a bit iffy. Again, similar reasoning to #87 should mean that it should work in principle (i.e. don't forget to define the Regarding the syntax error: it would be ok to fix this as it could be use for more benign applications too. PR welcome. |
Yeah it seems impossible with current Julia. I can't see any way around the invalidations from stuff like this. I was trying to think if there is some way to write a struct MyFloat <: AbstractTraitWrapper{AbstractFloat}
x::Float64
end and somehow have this struct inherit all methods on Base.:+(x::T, y::T) where {T<:AbstractTraitWrapper; IsMyFloat{T}} = T(x.x + y.x) so that it wouldn't invalidate other |
I'm not following here:
You don't refer to above example with that, right? |
Sorry I was thinking of the example in #87, not the one in here. |
There is a workaround for this but in case you'd like to support it, the following syntax does not work. My use-case is to build a generic constructor for any type
D
satisfying some trait:This will raise the following error:
The workaround is to pass a symbol:
which works.
The text was updated successfully, but these errors were encountered: