[Ecls-list] turn off auto declares
Dean O'Connor
dean.oconnor at ite.com.au
Wed Nov 23 17:10:15 UTC 2005
nice one !!! That certainly helps finding certain kinds of insidious
errors :)
I don't know if this is possible, but it would also be great if there
was a further option for setq to trip errors only at execution time.
I my situation, my globals (dynamic specials) are created/bound in a
root function and accessed by functions called by that execution path.
(I am trying to use this method for allowing per thread "globals" on an
execution path.)
For example:
> (SETQ EXT:*ACTION-ON-UNDEFINED-VARIABLE* 'ERROR)
Error
> (defun foo ()
(let ((*global* 1))
(declare (special *global*))
(print *global*)
(bar)
(print *global*)))
Foo
> (defun bar ()
(setq *global* 2)
(setq undefined-local 3))
Undefined variable referenced in interpreted code.
Name: *Global*
Top level.
>>
Instead, if the defun of bar didn't throw an error, but when foo is
called, thus calling bar, only the 2nd setq fails, since at this point
*global* is bound, whereas undefined-local is not.
If this were possible, I could instantly find all any old global vars
that I missed making into local vars, at execution time.
Better at execution time, than being undetected altogether :)
Cheers
Dean.
Juan Jose Garcia Ripoll wrote:
>On Tue, 2005-11-22 at 01:58 +1100, Dean O'Connor wrote:
>
>
>>Well errr ... I don't know really. I just found that CMUCL link and
>>thought it might be a clue for ECL.
>>
>>Perhaps I am asking something silly .... but let me be more specific ...
>>
>>I am converting old Emac Lisp scripts to work under ECL. These old
>>scripts used global variables everywhere. They just set them in
>>functions with a "setq".
>>There are no LETs or even DEFVAR/PARAMETERS.
>>I am trying to convert them to local (and some dynamic/special)
>>variables, but its difficult to be sure I don't miss any.
>>
>>
>
>Latest change (in CVS):
>
> - A new global variable EXT:*ACTION-ON-UNDEFINED-VARIABLE* controls whether
> the interpreter complains when you try to assign a value to a symbol that
> has not been defined as variable. An example
>
> > (SETQ S 1) ; No complain
> 1
> > (SETQ EXT:*ACTION-ON-UNDEFINED-VARIABLE* 'ERROR)
> ERROR
> > (SETQ X 1) ; Ooops, X had not been defined before!
> Undefined variable referenced in interpreted code.
> Name: X
> >> :q
> > (DEFVAR X 1)
> X
> > (SETQ X 1)
> 1
>
>I am not sure about the interaction between this code and code that
>assumes global variables can be defined by SETQ. Notice however an
>important difference between ECL and CMUCL:
>
> In standard ECL, doing (SETQ X 1) on a previously
> undefined variable X does not make X special!!!!
>
>In otherwords, (SETQ X 1) assigns a value to the symbol X but is not
>equivalent to (DEFPARAMETER X 1).
>
>Regards
>
>Juanjo
>
>
>
More information about the ecl-devel
mailing list