Hi, I'm trying to nest environments in my Jolt code as I would in Scheme (but there I'd use a 'let*' instead of just 'let'):
(define test (lambda (foo) (let ((bar 1) (bot (lambda () (set bar 3)))) (printf "bar is %d\n" bar) (set bar 2) (printf "bar is %d\n" bar) (bot) (printf "bar is %d\n" bar)))) (test) I'd want to see: bar is 1 bar is 2 bar is 3 However, this code produces a compile-time error: Object.st:138 Object error: Compiler.st:917 Compiler errorUndefined: Compiler.st:704 ? [] Object.st:84 UndefinedObject ifNil: Compiler.st:195 Compiler lookupVariable:ifAbsent: Compiler.st:704 Compiler setVariable:from: Compiler.st:697 Compiler xSet: Compiler.st:337 Compiler performSyntax:with: Compiler.st:306 Compiler translateExpression: Compiler.st:269 Expression translate: [...] undefined: bar Upon investigation, the error is caused by the reference to 'bar' in the innermost lambda. How do I construct a closure in Jolt that can bind to variables that are local to the function in which the closure was created? I'd like this in order to implement a useful callback function (which modifies the state of its lexical environment, regardless of its caller). I don't want to use global variables due to multithreading concerns. Thanks for any help you can offer, -- Michael FIG <[EMAIL PROTECTED]> //\ http://michael.fig.org/ \// _______________________________________________ fonc mailing list fonc@vpri.org http://vpri.org/mailman/listinfo/fonc