[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: declare in with-slots

>The correct syntax is:
>	(multiple-value-bind (x y z)
>	    (multiple-return-value-function a b c)
>	  (declare (fixnum x y z))
>	  ...
>	)

OK, so how about:

	(with-slots (x y z) obj
	  (declare (fixnum x y z))


though, as Glenn Kramer has pointed out, the declaration is actually
redundent because the types can be deduced from the class definition.
Other declarations, like compilation optimization and special declarations,
cannot, however. There is a question of whether those should be allowed.

The expansion of with-slots would be something like:

	  ( (x (the fixnum (slot-value 'x obj)))
	    (y (the fixnum (slot-value 'y obj)))
	    (z (the fixnum (slot-value 'z obj)))
	    <any other declarations>


so the expansion would, indeed, have to check for type declarations on the
pseudovariables. symbol-macrolet does not, however.

If type declarations are allowed, then the question of what to do should
a conflict between the declaration of types in the class and the local
declaration occurs. There are a number of options here, everything from
leaving it up to the implementation to decide to checking if the local
declaration is wider than the declaration in the class (e.g. a local
declaration of number when the class declared the slot to be fixnum)
and signalling an error. Having a narrower declaration (e.g. a
local declaration of fixnum when the class declared the slot to be
number) could have important uses in some cases.