Re: [julia-users] metaprogramming and encapsulation

2016-10-02 Thread Fengyang Wang
It is not in general possible to recover the function itself from a method, as methods are specific to types and not functions. Multiple functions can share methods if those functions have the same type. In the case of generic (or singleton) functions, you can recover the function from the

Re: [julia-users] metaprogramming and encapsulation

2016-10-02 Thread Carlo Lucibello
that could be handy indeed, thanks. I would also like to automatize the process using ```julia mlist = methodswith(A, ModA) ``` but looks like objects of type Method are not callable ```julia julia> mlist[1](1) ERROR: MethodError: objects of type Method are not callable in eval_user_input(::Any,

Re: [julia-users] metaprogramming and encapsulation

2016-09-26 Thread Mauro
This macro might work for you https://github.com/JuliaLang/DataStructures.jl/blob/8422ca9f66bfaa0f257b2bbbc8637c844d49ea68/src/delegate.jl On Mon, 2016-09-26 at 16:31, Carlo Lucibello wrote: > Hi everybody, > I'm looking for a metaprogramming trick to solve the

[julia-users] metaprogramming and encapsulation

2016-09-26 Thread Carlo Lucibello
Hi everybody, I'm looking for a metaprogramming trick to solve the following problem (I'm confident it can be done efficiently with julia) . Let's say I have defined a type in a module along with some methods: module ModA export A,f1,f2,f3 type A ... end f1(a::A, x::Int) = ... f2(x, a::A, y)