[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"is a" relationships
- To: self-interest@self.stanford.edu
- Subject: "is a" relationships
- From: jbm@hal.com (Brad Might)
- Date: Wed, 23 Sep 92 18:43:58 CDT
- Resent-date: Wed, 23 Sep 92 16:35:42 PDT
- Resent-from: Urs Hoelzle <urs@otis>
- Resent-message-id: <9209232335.AA11568@otis.Stanford.Edu>
- Resent-to: real-self-interest
Trying to determine how "is a" relationships could/should be specified in
Self.
eg. cat "is a" mammal "is a" animal.
c++ does this by subclassing
class animal {};
class mammal : public animal {} ;
class cat : public mammal {} ;
With self we could go several ways (code off the top of my head, please
forgive syntax and/or structure):
using a c++ like method, we duplicate the Base class in the child, then add
our own thing.
I don't like this method too much, as changes made to animal may not be
reflected into the copy of animal within mammal.
Also, mammal must avoid duplicating slot names, or must override them
completely, ie. cannot ovverride and then call "super"
prototypes _AddSlots: (| animal = ("some stuff") |)
prototypes _AddSlots: (| mammal = animal copy |)
prototypes mammal _AddSlots: (| "mammal specific stuff here"|)
This is what I have tried, is it the way to go ?
prototypes _AddSlots: (|
animal = (|
parent* = traits animal.
"object specific stuff here".
|).
mammal = (|
parent* = traits mammal.
inherit**. "at initialization (copy), this slot will be
filled in with a copy of prototypes animal"
"mammal stuff"
|).
|)
inherit is a parent of lesser importance so that methods can be overridden
as desired.
What bugs me about this one, is the copy required to fill in "inherit" at
object initialization (copy) time. Is this how its done ?
brad