"is a" relationships

Brad Might jbm at hal.com
Wed Sep 23 23:43:58 UTC 1992



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

	




More information about the Self-interest mailing list