Suppose I have the following class:
(defclass sequence-grammar (grammar)
((sequence :initarg :sequence :accessor sequence)))
Now I want to define a new class:
(defclass string-grammar (sequence-grammar))
However, I'd really like string-grammar to have an :initarg and
:accessor for the sequence slot called :string. This seems to work (in
ACL 6.2 anyway) but I can't find the place in the CLHS that says it
should:
(defclass string-grammar (sequence-grammar)
((sequence :initarg :string :accessor string)))
That is, with these definitions, I can say:
[6c] BAZ(125): (defvar *s* (make-instance 'string-grammar :string "foo"))
*S*
[6c] BAZ(133): *s*
#<STRING-GRAMMAR @ #x7149217a>
[6c] BAZ(134): (sequence *s*)
"foo"
Sec. 4.3.4.1 Examples of Inheritance seems to be doing a similar thing
but there isn't a ton of explination there. And I thought the examples
were non-normative anyway. Any pointers?
-Peter
--
Peter Seibel ·····@javamonkey.com
The intellectual level needed for system design is in general
grossly underestimated. I am convinced more than ever that this
type of work is very difficult and that every effort to do it with
other than the best people is doomed to either failure or moderate
success at enormous expense. --Edsger Dijkstra
Peter Seibel <·····@javamonkey.com> writes:
> Suppose I have the following class:
>
> (defclass sequence-grammar (grammar)
> ((sequence :initarg :sequence :accessor sequence)))
>
> Now I want to define a new class:
>
> (defclass string-grammar (sequence-grammar))
>
> However, I'd really like string-grammar to have an :initarg and
> :accessor for the sequence slot called :string. This seems to work (in
> ACL 6.2 anyway) but I can't find the place in the CLHS that says it
> should:
>
> (defclass string-grammar (sequence-grammar)
> ((sequence :initarg :string :accessor string)))
This is the way it works in all Lisps that follow the Spec.
> Sec. 4.3.4.1 Examples of Inheritance seems to be doing a similar thing
> but there isn't a ton of explination there. And I thought the examples
> were non-normative anyway. Any pointers?
See 7.5.3 Inheritance of Slots and Slot Options
Tim
Timothy Moore <·····@bricoworks.com> writes:
> See 7.5.3 Inheritance of Slots and Slot Options
Ah, perfect. Thanks.
-Peter
--
Peter Seibel ·····@javamonkey.com
The intellectual level needed for system design is in general
grossly underestimated. I am convinced more than ever that this
type of work is very difficult and that every effort to do it with
other than the best people is doomed to either failure or moderate
success at enormous expense. --Edsger Dijkstra