Hi Gavin, Yes, thanks, I see what you mean. Actually, your example will work if you change it slightly to:
[`[StdOut println: [String value_: ,arg]] eval])) Apparently the string becomes a primitive char* at some point; at least that's my guess... Could you elaborate a bit, though, on the first option you presented, i.e. passing an environment to eval? For example, where would you get that environment object from? And how would eval deal with it? By just overwriting the "environment" field of the Compiler object? Thanks, Hans On Thursday 06 September 2007 13:38, Gavin Romig-Koch wrote: > Hi Hans, > > Indeed eval has no access to the local environment inside grr. One > could write an eval that accepted an environment, but in this case it is > not necessary. > > > (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 > > This is where quasiquote becomes handy: > > [`[StdOut println: ,arg] eval])) ; this doesn't actually work though(?!) > > Notice the comma in front of arg. This causes arg to be evaluated and > it's value substituted into the list being built by quasiquote, so eval > itself never sees 'arg', but instead sees it's value. Unfortunately > this doesn't actually work, the println prints out a large integer > (probably the integer value of some pointer), rather than 'test' (when > grr is called with '"test"). I suspect this is some subtlety about the > interaction between quasiquote/unquote and using quote to convert > primitive ints and pointers to non-primitive SmallInt's and Strings that > I'm not getting. > > > > -gavin... -- If we cannot live so as to be happy, let us at least live so as to deserve it -- Immanuel Hermann Fichte A liberal is a person whose interests aren't at stake at the moment -- Willis Player Ark Linux - Linux for the Masses (http://arklinux.org) Hans Schippers Aspirant FWO - Vlaanderen 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
