[Openmcl-devel] Compiler warnings

Ron Garret ron at flownet.com
Sun Oct 18 03:40:35 PDT 2009


On Oct 18, 2009, at 3:28 AM, Taoufik Dachraoui wrote:

> I am not talking about the warnings, warnings are sometimes  
> necessary, and I understand the
> difference between dynamic and lexical variables.

But not, apparently, the difference between compile-time and run-time.

> I am puzzled by the special operator THE as implemented in CCL. Why  
> the THE operator
> expects a special variable

It doesn't.

> and not simply specifies the value returned by the expression as
> described in the CLHS:
>
> again the example I gave shows the awkwardness:
>
> ? (setf x 3)
> 3
> ? (the fixnum x)
> ;Compiler warnings :
> ;   In an anonymous lambda form: Undeclared free variable X
> 3
> ? (defun f () x)
> ;Compiler warnings :
> ;   In F: Undeclared free variable X
> F
> ? (the fixnum (f))
>
> The last form shows that the THE operator did not care about the x  
> it just specified the
> value of the result without complaining, but if the expression  
> directly contain a non defined
> variable as in the first form, the THE operator raise a warning.

This has nothing to do with THE.  This warning is generated by the  
compiler.  In CCL, most, but not all, expressions are compiled before  
they are run.  *Any* expression sufficiently complex to trigger a  
compilation will produce the warning:

Welcome to Clozure Common Lisp Version 1.4-dev-r12726M-trunk   
(DarwinX8664)!
? (setf x 1)
1
? (let ((y x)) y)
;Compiler warnings :
;   In an anonymous lambda form: Undeclared free variable X
1
? ((lambda () x))
;Compiler warnings :
;   In an anonymous lambda form: Undeclared free variable X
1

"THE" is a red-herring (except insofar as it is one of the forms that  
triggers a compilation rather than using the simple evaluator).

> Also, two other things one again about the THE operator and one  
> about SETF.
>
> I would like to understand; what is the purpose of the THE operator  
> if it does not raise
> an error if the expression returns a value with a type different  
> from the specified one?

It's to help the compiler produce more efficient code.

> As you saw in the examples that I provided in my previous  
> submission, we see that CMUCL
> declares the variables defined by SETF as special (so dynamic),  
> unlike CCL the variables are not dynamic (but lexical, at least they  
> behave like that as I showed in the examples).

No, you haven't, and they aren't.  See my earlier response to you in  
this thread.

rg





More information about the Openmcl-devel mailing list