[Openmcl-devel] Trunk and released version

Tim Bradshaw tfb at tfeb.org
Fri Aug 14 09:16:51 UTC 2009


On 13 Aug 2009, at 17:43, Ron Garret wrote:

> I dunno, I don't think copying the declarations is all that  
> inexplicable.  After all, an implementation is allowed to assign VAR  
> instead of rebinding it as CCL does, in which case you'd have no  
> choice but to have the declarations apply in the scope of the result  
> form.

I agree with this.  I think one would have to ask Kent Pitman or  
someone else who is good at interpreting the standard's intent, but I  
think it's at least reasonable to assume that the declaration should  
apply to all bindings of the variable in the form (if indeed there is  
more than one).

The counter-argument is that insisting on that would make declarations  
much weaker, and perhaps unusably weak.  For instance one might want  
to say something like this (this is not intended to be idiomatic code):

(defun grob (lio)
   (let ((s 0))
     (dotimes (i lio s)
       (declare (type integer i)) ; Oops
       (incf s i))))

But actually, you have to say this:


(defun grob (lio)
   (let ((s 0))
     (dotimes (i lio s)
       (declare (type (or integer null) i)) ; OK
       (incf s i)))) ; May fail now

Or in fact this

(defun grob (lio)
   (let ((s 0))
     (dotimes (i lio s)
       (locally
         (declare (type integer i))
         (incf s i)))))

Which is horrible.

So, clearly, having the declaration apply only within the body of the  
loop makes for code which does what you'd expect.  However it probably  
constrains the implementation a bit, as the easiest way to deal with  
the binding-exists-in-the-result-form requirement has to be to make a  
new binding there.

--tim



More information about the Openmcl-devel mailing list