[julia-users] Detecting free variables in an anonymous function

2015-05-08 Thread Jonathan Malmaud
Say I have a quoted anonymous function, like :(x->y=1; y+x+z). I'd like to determine that 'z' is not bound within the function (ie, is a reference to an enclosing outer/global scope). What's a good way to do it? I know I could recursively analyze the Expr, keeping track of which variables were

Re: [julia-users] Detecting free variables in an anonymous function

2015-05-08 Thread Jameson Nash
You can call expand() on the AST, and let the frontend lower the code into a form that is easier to analyze. In particular: ``` julia> expand( :(x->y=1; y+x+z) ).args[1].ast.args[2][1] 1-element Array{Any,1}: :y ``` On Fri, May 8, 2015 at 2:41 PM Jonathan Malmaud wrote: > Say I have a quoted a