Jim Newton
12/21/2015 4:05:00 PM
Hi Pascal, thanks for the answers, but perhaps you missed my point.
I am not trying to define classes consistent with declarations.
I'm trying to write a function that detects declarations in code which I didn't write.
Actually my code expands to a destructuring-bind form, given a destructuring lambda list, and a body (among other things).
Think of it as follows, given a destructuring-bind form which may have
declarations starting in its 2nd argument. I want to build a mapping from variable name
to type specifier.
(destructuring-bind (a b c d) value
(declare (type x A))
(declare (ignore x) (inline z))
(declare (x y z))
...)
When I encounter (declare (type x A)) then I know this is a type definition,
When I encounter (declare (ignore x) (inline z)) I know it is not a type def.
But when I encounter (declare (x y z)) I don't know what it is.
> A code walker has to parse (and execute) all the code, like an
> interpreter or a compiler would do, to learn about types and other
> things. Or, often, it can just make some assumptions (ie. expect the
> program is conforming).
>
If I could assume that the code up to this point has already been compiled and executed,
and thus if (declare (x ..)) is a type declaration then X is already a defined type,
then I could test for that. After all, it would be an error for restructuring-bind anyway
if not yet defined. Right?