Hi Gavin, Thanks for the suggestion. At first sight, that looks perfect, however eval seems to be blind to the current *local* environment. I.e. while eval'ing an expression which contains variables globally defined with (define), works fine, arguments or local (let) variales can't be resolved:
(define xx '"xx") (define grr (lambda (arg) [`[StdOut println: xx] eval] ; will indeed print "xx" [`[StdOut println: arg] eval])) ; will result in "undefined: arg" error (grr '"test") Is there a good reason for this behaviour? Is there a way to circumvent it? Thanks, Hans On Wednesday 05 September 2007 14:35, Gavin Romig-Koch wrote: > SainTiss wrote: > > I was suggested to use something similar to Scheme's 'apply', but I > > didn't find a similar construct in jolt... Is there? > > In Lisp-ish languages 'apply' is something like: > > (define apply > (lambda (func args) > (eval (cons func args)))) > > That is, assuming func is a function and args is a list of arguments, > append func to the front of the args and eval the result. > > The difficutly in jolt is that while in lisp, args is a linked list, and > appending func to it doesn't change it, in jolt args is an Array, which > has to be copied to avoid changing it, so you want > to do something like ArrayedCollection::addFront, but do it into a new > array rather than > modifying the existing array. One way to do that would be to add a new > constructor to Expression (say Expression::function:arguments:) which > does just that. > > So then apply is just: > > (define apply > (lambda (func args) > [[Expression function: func arguments: args] eval])) > > > > -gavin... -- A liberal is a person whose interests aren't at stake at the moment -- Willis Player Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 38 71 Fax: +32 3 265 37 77 _______________________________________________ fonc mailing list [email protected] http://vpri.org/mailman/listinfo/fonc
