Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-11 Thread Yichao Yu
On Thu, Aug 11, 2016 at 4:21 PM, Andrei Zh wrote: > >> `slotnames` of LambdaInfo should have what you want. >> Do note that the name is not unique. >> > > > Do you mean that if's, loops, etc. may contain variables of the same name > but with different slot? > Correct.

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-11 Thread Andrei Zh
> > > `slotnames` of LambdaInfo should have what you want. > Do note that the name is not unique. > Do you mean that if's, loops, etc. may contain variables of the same name but with different slot?

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-10 Thread Yichao Yu
On Thu, Aug 11, 2016 at 6:40 AM, Andrei Zh wrote: > One more question related to the topic. I try to get function body > expression in Julia 0.5 using: > > lambda = methods(func, types).ms[1].lambda_template > Base.uncompressed_ast(lambda) > > However this gives an expression with argument names

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-10 Thread Andrei Zh
One more question related to the topic. I try to get function body expression in Julia 0.5 using: lambda = methods(func, types).ms[1].lambda_template Base.uncompressed_ast(lambda) However this gives an expression with argument names replaced by `SlotNumber` (e.g. `_2`). Is there a way to get f

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-08 Thread Andrei Zh
Thanks, this makes sense. Just for clarification: > It strongly depend on what you want to do and whether you care about what > they represent. > I want to apply transformations (mostly) to algebraic expressions and function calls in order to simplify them, replace argument names, find deri

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-07 Thread Yichao Yu
On Mon, Aug 8, 2016 at 7:14 AM, Andrei Zh wrote: > Then maybe the whole approach is incorrect, so let me describe what I try > to achieve. > > The general idea is to extract AST of a function and do some > Without knowing more higher level information, if this is what you want to do then > tra

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-07 Thread Andrei Zh
Then maybe the whole approach is incorrect, so let me describe what I try to achieve. The general idea is to extract AST of a function and do some transformations on it. To do so, I use `Base.uncompressed_ast` (borrowed from ReverseDiffSource.jl

Re: [julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-07 Thread Yichao Yu
On Mon, Aug 8, 2016 at 3:57 AM, Andrei Zh wrote: > While parsing Julia expressions, I noticed that sometimes calls to > This shouldn't happen. > global functions resolve to `GloablRef` and sometimes to > and GlobalRef should only happen during lowering. > getfield(Module, func). Could someb

[julia-users] GlobalRef(Module, func) vs. :(Module.func)

2016-08-07 Thread Andrei Zh
While parsing Julia expressions, I noticed that sometimes calls to global functions resolve to `GloablRef` and sometimes to getfield(Module, func). Could somebody please clarify: 1. Why do we need both? 2. Is it safe to replace one by the other (assuming only modules and functions are involved