[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tracing SETF on structures
>From: jmccarth%stimpy@cs.umass.edu (Joe McCarthy)
>Subject: Tracing SETF on structures
>is executed. In Section 5.4 of the Allegro CL Common Lisp User Guide
>(Version 4.1, March 1992, page 5-29), the following example is given:
>
> (trace ((method (setf slot-1) (t baz))))
> (trace ((method foo :before (integer))))
> (trace ((method foo :after (integer))))
>
>Unfortunately, I am unable to interpret how I can use this example to
>set up the tracing I want. In particular, I'm not sure what SLOT-1,
>and (T BAZ) mean.
>
>Taking a guess at a mapping, I tried the following
>
> (trace ((method (setf related-np) (t np-record))))
>
>but this yielded:
>
>Error: (METHOD (SETF RELATED-NP) (T NP-RECORD)) does not have a function
> definition
>
>Can anyone help me figure out how to set up the desired tracing?
Hi Joe,
This is a problem related to the the naming of SETF methods
under CLOS in allegro.
The short answer is that the call to trace is
(trace ((method (setf np-record-related-np) (t np-record))))
instead of (as you had)
> (trace ((method (setf related-np) (t np-record))))
The explanation is short, too:
SETF functions (see CLtL2, sec 7.1) are a list whose car is SETF.
In allegro, SETF functions seem to be treated as method
specifiers on the generic SETF function.
When DEFSTRUCT creates a slot-reader function,
such as NP-RECORD-RELATED-NP (a function of 1 arg of type NP-RECORD)
it automatically creates a slot-writer function,
(SETF NP-RECORD-RELATED-NP), which will take 2 arguments:
the new value, and an NP-RECORD.
The specification for tracing methods is
((METHOD method-name) arg-type-list)
which here becomes
((method (setf NP-RECORD-RELATED-NP)) (T NP-RECORD))
--ts