rif <[EMAIL PROTECTED]> writes: > I'm getting hopelessly confused by aliens. Rather than try to explain > it all at once, I've reduced one of my questions to its simplest > possible form. If anyone can explain this behavior to me, I would be > greatful. The question is in the comments in the included file. This > file can be compiled and loaded.
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > (declaim (optimize (speed 1) (safety 3) (debug 3))) > > (alien:def-alien-type foo > (alien:struct foo (uint c-call:unsigned-int))) > > (defvar *f* (alien:make-alien foo)) > > ;; Either of these would work: > ;; (setf (alien:slot *f* 'uint) 35) > ;; (setf (alien:slot (the (alien:alien (* foo)) *f*) 'uint) 35) > > ;; This would causes a load-time error: > ;; (setf (alien:slot (the (alien:alien foo) *f*) 'uint) 35) > > ;; This is understable, because *f* is an (alien:alien (* foo)), > ;; NOT an (alien:alien foo) > > ;; But why does this work???? The manual says that "If struct-or-union is a pointer to a structure or union, then it is automatically dereferenced." http://common-lisp.net/project/cmucl/doc/cmu-user/aliens.html#toc254 I think that cmucl does the right thing but if you insist in declaring the f as a (the (alien:alien foo) *f*) which it is not, it probably trust your declaration. Immanuel
