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)

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 h

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!

Re: Newbie question: bind a variable on the fly

2006-06-11 Thread Jon Wilson
Hi Vincent, Don't try this just yet. I want other people to give it a look-over and make sure it isn't foolish and dangerous before anybody lets it out in the wild. This doesn't use the exception, and it doesn't use a c function, and it doesn't do database lookups. However, it can be used

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).

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 h