-
Notifications
You must be signed in to change notification settings - Fork 6
super call #30
Comments
Methods within a trait definition do not belong to that trait, i.e. they are not dispatched on based on the trait, only on the type. Thus your @traitimpl T1{Int64} begin
fun(x::Int64) = 2x
end makes a method This is not going to change, thus I'm closing this. But feel free to use this issue to ask further questions concerning this. |
Then the question is how can i dispatch the to the call to the fun based on trait type T1? |
I think you're a bit confused with object oriented programming. The function Anyway, you may want to make functions which dispatch on that trait
Hope that helps? |
So basically you are using the traits as a collection of methods nothing more, they are not like mixins. how can i make f(y) to call @traitfn f{Y; T1{Y}}(y::Y) = 1? |
First, note that this very common pattern in OO languages is not used much in Julia, see JuliaLang/julia#13123. I'm not sure quite why. Anyway, you can do it like so:
that call directly calls the method which contains the logic for PS: @bjmtrk, better quote the macrocalls with backticks " |
Hi,
I am a bit confused how to do the super call.
Can we do something like this?
Thanks
The text was updated successfully, but these errors were encountered: