Okay, I’m trying to figure this out, so let me reveal my ignorance, and see if
anyone feels like filling in the cracks.
Typical object creation:
-
The object must be defined. This creates a template from which instances
are built, and forms the basis for type checking in strongly typed systems. -
Having a definition, we may declare an instance of the object. This
actually allocates memory towards the object, and fills in method pointers so
the methods declared in the definition work. -
The object may then run it’s constructor, filling in variables that were
left unfilled by the definition.
Object creation with inheritance:
-
The object must be defined, and the definition must include a mention of
the object’s superclass. -
We declare and instance as above. In addition to filling in methods and
allocating variables we defined, it adds in the superclass’s variables and
methods. It mixes the two namespaces, with our definition taking priority over
the superclass defnition. The language also provides a keyword to declare when
we want access to the superclass method instead of our own. -
The superclass constructor is run, then ours (I’m guessing), filling in
that which is appropriate.
Given these ideas, let’s examine the idea of declaring a class, and having
itself as a superclass.
Firstly, It might be of dubious use to be able to declare a superclass after
the first definition, but that’s a deeper question. Clearly, in the first
definition, it’s a syntax error, as you are asking to define something based
on something that doesn’t yet exist.
As to add on definition, the behavior I would expect is the interpreter or
compiler to say “Surely you did not mean to do that.”
Barring that, I would expect a stacked class. To contrast, a normal defintion
and inheritance. Posit a class
class point namespace: x, y, z, getx(), gety(), getz()
class conpoint namespace: getx(), gety(), getz(), convertfunc()
As opposed to:
class point namespace: x, y, z, getx(), gety(), getz()
class point’ namespace: x, y, z, getx(), gety(), getz()
I.e. a pointless union with twice the storage of a regular defintion.
In the case that the initial definition contains nothing
class point namespace:
class point’ namespace: x, y, z, getx(), gety(), getz()
All you get is a silly namespace boundary, like two fences right next to each
other. Since there is no namespace collision possible, you never notice.
···
–
The way we describe our world shows how we think of our world.
How we think of our world governs how we interpret our world.
How we interpret our world directs how we participate in the world.
How we participate in the world shapes the world.
http://www.hacksaw.org – http://www.privatecircus.com – KB1FVD