[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Reply to reply to DESTRUCTURING C.H.
- To: lisp-forum at MIT-MC
- Subject: Reply to reply to DESTRUCTURING C.H.
- From: Guy.Steele at CMU-10A
- Date: Wed ,10 Jun 81 17:53:00 EDT
- In-reply-to: George J. Carrette's message of 10 Jun 81 15:54-EST
Unfortunately there is a bad interaction between destructuring
of DEFSTRUCT structures and defaulting of components.
Consider a slightly modified version of GJC's example:
(DEFSTRUCT FOO A B (C 'TANG)) ;FOO is an astronaut (see Chineual)
Now when one writes #{FOO A: 1 B: 2} I assume that means the same
as #,(MAKE-FOO A '1 B '2), on the Aunt Agatha principle: I can't
think of what else it might usefully mean. Assuming this to be true,
then we find that writing
(DSETQ #{FOO A: X B: Y} Z)
is identical to writing
(DSETQ #,(MAKE-FOO A 'X B 'Y) Z)
which, because of the defaulting mechanism of DEFSTRUCT, is the same as
(DSETQ #,(MAKE-FOO A 'X B 'Y C 'TANG) Z)
which is the same as
(DSETQ #{FOO A: X B: Y C: TANG} Z)
because of the defaulting of the C slot, which happens at READ time
when the structure is constructed. Therefore, like it or not,
the variable TANG gets setq'd as well as X and Y! I don't think you
can get rid of this effect without either making DSETQ not really
data-directed, or throwing away the component-defaulting mechanism
of DEFSTRUCT (which would be unaccetable, I think).
--Guy