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...
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc