[Ecls-list] unbound-variable handler

Dean O'Connor dean.oconnor at ite.com.au
Tue Jun 19 04:08:18 UTC 2007


thanks a lot. That got me much further. This exits cleanly, but I need 
it to continue executing the nested expressions, using value NIL for the 
unbound variable.

The aim was that if a scripts said something like:

    (when VAR1
          (print "yep"))

Then if VAR1 was never bound by a SETQ or whatever, then VAR1's value 
would simply returned as NIL (by a handler) instead of entering debug.

I am trying to RTFM to see if I can sort of continue, but if anyone has 
the answer handy, I would much appreciate it.

cheers
deano


Pierre THIERRY wrote:
> Scribit Dean O'Connor dies 19/06/2007 hora 03:03:
>   
>> I am trying to setup a handler to catch "unbound-variable".
>>     
>
> The thing is, if I understand the condition system correctly, you need
> to setup a restart around the expression that might be unbound:
>
> (handler-bind
>     ((unbound-variable (lambda (c)
> 			 (declare (ignore c))
> 			 (invoke-restart 'use-nil))))
>   (not (restart-case
> 	   not-yet-bound-variable
> 	 (use-nil () nil))))
>
> Works in SBCL and ECL (yields t).
>
> Quickly,
> Pierre
>   
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list
>   




More information about the ecl-devel mailing list