[self-interest] Re: simple object model

Uladzimir Liashkevich uml at csp.org.by
Fri Apr 6 17:25:22 UTC 2001


> 
> > In addition, this solution doesn't look acceptable for frequent use.
> > It would be nice to have a construction equivalent to (| x = aX. y =
> > aY |) that is evaluated at run-time on every occurance.
> 
> Where would this be used? Note that quoting conventions can become very
> complex for the kind of expression you want. Some languages have
> something similar for creating function creating functions.
> 
> I just noticed that since the assignment primitive returns the modified
> object, the non constant slot, non cloning version of the example could
> have been written more simply as
> 
>              ... ^ ( (| x. y |) x: sX) y: sY

It looks much better.
Idea! Not I know what I actually wanted:
  prototypes point copyWith: (x 3 y 4)
I.e. initializing an object with a hash.
The copyWith: method can be easily implemented in Self, but it misses
literal hashes (more importantly, initialized at run-time).

> 
> > So I would suggest to preserve the idea of using _map_ in each object
> > transparently.
> 
> Well, I did mention a not so transparent map-like variation:
> 
>   ((x : y :) 3 4)
> 
> The embedded list with the two indirect slots works as both a map and
> as an anonymous parent (by the way, except for assignable parents and
> directed resends do we actually gain anything by making parents visible
> at the base level?). If you clone this, you will only take up three

For example, hierarchies of traits/prototypes.
Also for eliminating ambiguities:
  globals app1 myObject
  globals app2 myObject

> words. And the shared list at the begining of this object and its clone
> would be a sort of type information.

At first glance I liked the idea of declaring maps, but now I see some
drawbacks here. The main is that the notation is position-dependant,
i.e. if later you want to add another slot to the map - (x : x1 : y :),
you should carefully keep track of positions in the list of slot
initializers - ((x : x1 : y :) 3 10 4). But what if the number of slots
is very high?
IMHO, it is an error-prone construction.

> 
> > For example, you may consider introducing implicit parent for all
> > objects. I.e. even empty object () would have a parent 'traits
> > basicBehavior'.
> 
> In Self the primitive interface is much cleaner than in Smalltalk,
> since they look like normal message sends and use the normal send
> bytecodes. But then things become a little strange - how do you look
> them up? They have to be found in some hidden table deep inside the
> virtual machine or else you couldn't send primitive messages to objects
> like ().

In my implementations I have a hidden object with all primitive slots.
When a message name begins with underscore then a lookup is performed in
the hidden object.

-- 

Uladzimir.



More information about the Self-interest mailing list