Looking for a macro API to extract free variables from an expression?

6 messages
Open this post in threaded view
|

Looking for a macro API to extract free variables from an expression?

 has anyone done it already? Thanks, Stephane
Open this post in threaded view
|

Re: Looking for a macro API to extract free variables from an expression?

 what do you mean with free variables?2011/11/2 sledorze has anyone done it already? Thanks, Stephane -- View this message in context: http://haxe.1354130.n2.nabble.com/Looking-for-a-macro-API-to-extract-free-variables-from-an-expression-tp6955161p6955161.html Sent from the Haxe mailing list archive at Nabble.com. -- haXe - an open source web programming language http://haxe.org -- haXe - an open source web programming language http://haxe.org
Open this post in threaded view
|

Re: Looking for a macro API to extract free variables from an expression?

 It's a concept from lambda calculus. Given haXe's syntax it's a bit less clear than in Lisp for example. Consider the following expression: {      var a;      function b() return b+x;      b(a);      b(y);      for (i in z) b(i);      b(i); } In that example x,y and z are free, while a,b are bound. As for i, it is bound within the body of the for loop, but not in the last statement of the block. Basically a variable is free within a given scope, if it is "undefined". Given haXe's relatively rich syntax compared to lambda expressions (meaning those in lambda calculus) and given that in haXe an identifier is not necessarily a variable, this concept has to be bent a little to be applied to haXe. On Wed, Nov 2, 2011 at 3:43 PM, Cauê Waneck <[hidden email]> wrote: > what do you mean with free variables? > > 2011/11/2 sledorze <[hidden email]> >> >> has anyone done it already? >> >> Thanks, >> Stephane >> >> >> -- >> View this message in context: >> http://haxe.1354130.n2.nabble.com/Looking-for-a-macro-API-to-extract-free-variables-from-an-expression-tp6955161p6955161.html>> Sent from the Haxe mailing list archive at Nabble.com. >> >> -- >> haXe - an open source web programming language >> http://haxe.org> > > -- > haXe - an open source web programming language > http://haxe.org> -- haXe - an open source web programming language http://haxe.org
Open this post in threaded view
|

Re: Looking for a macro API to extract free variables from an expression?

 In reply to this post by Cauê W. I think Juraj explained it well.. :) Intuitively; They're the identifiers with the name of the parameters of the function with which you need to wrap the expression so that the compiler would not complain about unbound identifiers. (as you just bound them by introducing them into the scope via the parameters). like that: given this body: var x = y + 5; => function (y) { // this body had one free variable; y.   var x = y +5; } So? got that in your libraries?