Thanks everyone! I also find this helpful: https://github.com/JuliaLang/julia/issues/1974 A very related issue that the authors of Julia discussed.
In scala, object.f(args) is implemented as f(object, args). For Julia, maybe this implementation would harm the performance. Anyway, It's fine to use f(object, args) :) On Wednesday, October 7, 2015 at 5:46:56 PM UTC+2, David Gold wrote: > > See perhaps > https://groups.google.com/forum/?hl=en#!topic/julia-dev/V1HJcHQz4JE > > On Wednesday, October 7, 2015 at 8:13:33 AM UTC-7, cheng wang wrote: >> >> Hello everyone, >> >> In some cases, I would like to make a function belongs to an object. >> In classical OO, we do something like object.f(args...). >> In Julia, we could do it like this: f(object, args...). >> >> So I was wandering if there is some way to do following: >> I write object.f(args...), while julia could know it actual means >> f(object, args...). >> >> One naive way to implement this is in two steps: >> first, the compiler search for a field of object equal to f, if it's not >> found, >> then, compiler search for a function like f, and the invoke it. >> >> Looking forward for your opinions! >> >