-
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
M3/multitraits #2
base: master
Are you sure you want to change the base?
Conversation
Depends on whether TT = esc(:TT73840) or TT = esc(gensym())
Part of the addition looks like so (from the README): Dispatch on several traits It is also possible to dispatch on several traits: @traitfn f55{X, Y; TT1{X}, TT2{Y}}(x::X, y::Y)
@traitfn f55{X, Y; TT1{X}, TT2{Y}}(x::X, y::Y) = 1
@traitfn f55{X, Y; !TT1{X}, TT2{Y}}(x::X, y::Y) = 2
@traitfn f55{X, Y; TT1{X}, !TT2{Y}}(x::X, y::Y) = 3
@traitfn f55{X, Y; !TT1{X}, !TT2{Y}}(x::X, y::Y) = 4 Note that all methods need to feature the same traits (possibly |
This capability is very important to Traits being "trait-like" in the humanistic sense. |
Thanks @JeffreySarnoff, I take this as a +1 :-) |
Any update here? |
No. If you're at JuliaCon we could discuss it there. |
Hi, Would you have any updates on this? Thanks |
I don't have any plans with this, nor time. |
Friendly ping :) I dream of rust-like generics in Julia; this PR would make it so! |
Edit: this would be cool but increases the code complexity considerably. It might be easier to provide this functionality with generated functions. So, if demand for this feature materializes, revisit.
I think I'll merge this after a bit of settling. This came out of discussions over in JuliaLang/julia#13222. This adds:
This is a breaking change because now trait-functions need to be initialized via:
@traitfn f{X; TR{X}}(x::X)
(sans
=...
).I think this is as far as Holy Traits can be taken. Going further would get into the Traits.jl territory of trait-dispatch and trait-definitions via method specifications.