Newbie question: bind a variable on the fly

2006-06-13 Thread Vincent De Groote
Hello, Is there a way to catch an unbound-variable exception, bind the variable on the fly, and continue execution as if the exception didn't occurs ? I'd like to catch this exception in a c function: the exception context should be available, to retrieve the variable or function name. This

Re: Newbie question: bind a variable on the fly

2006-06-13 Thread Jonathan Wilson
Hi Neil, Neil Jerram wrote: Jon Wilson [EMAIL PROTECTED] writes: (define-macro (dyn-set! var val) `(begin (if (not (defined? (quote ,var))) (primitive-eval `(define ,(quote ,var) #f))) (set! ,var ,val))) (defined? 'undefined-symbol)

Re: Newbie question: bind a variable on the fly

2006-06-12 Thread Neil Jerram
Jon Wilson [EMAIL PROTECTED] writes: (define-macro (dyn-set! var val) `(begin (if (not (defined? (quote ,var))) (primitive-eval `(define ,(quote ,var) #f))) (set! ,var ,val))) (defined? 'undefined-symbol) ; = #f ;(set!

Newbie question: bind a variable on the fly

2006-06-10 Thread Vincent De Groote
Hello, Is there a way to catch an unbound-variable exception, bind the variable on the fly, and continue execution as if the exception didn't occurs ? I'd like to catch this exception in a c function: the exception context should be available, to retrieve the variable or function name. This

Re: Newbie question: bind a variable on the fly

2006-06-10 Thread Marius Vollmer
Vincent De Groote [EMAIL PROTECTED] writes: Is there a way to catch an unbound-variable exception, bind the variable on the fly, and continue execution as if the exception didn't occurs ? No, unfortunately not (but read on below for an alternative solution that doesn't use exceptions).