[Ecls-list] unbound-variable handler

Dean O'Connor dean.oconnor at ite.com.au
Sun Jun 24 15:45:25 UTC 2007


any other ideas to get around this? I really need a way of 
assigning/returning NIL to unbound variables and continuing execution.

cheers
deano

Dustin Long wrote:
> That's interesting....
>
> This works in clisp:
>
> (handler-bind ((unbound-variable (lambda (e) (invoke-restart 
> 'use-value nil)))) (format t "value is [~s]~%" x))
>
> but not in ECL. Does anyone know if unbound-variable is supposed to 
> establish the use-value restart? Or is that optional and 
> implementation dependent? I can't find any information about the 
> portability of such things.
>
> Dustin
>
> Dean O'Connor wrote:
>> 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
>>>       
>>
>> ------------------------------------------------------------------------- 
>>
>> 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