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) = 4Note 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.