Need feedback on simple idea

diegogomezdeck at consultar.com diegogomezdeck at consultar.com
Fri Apr 11 08:06:33 UTC 2003


Hi Stef,

I think you know my feeling.  WE NEED MORE RESEARCH!!!

Let's go for the next step!  What one is the next-step? I don't know at
all...  But we can't stay on the same state as 20 years ago.

IMHO, there are a lot of thing to try-to-improve so we need a better
environment to test ideas.  Let me explain some ideas [*]

Method Dictionaries in the object level (a la Visual-Smalltalk)

- Replace the class reference in each object to a reference to a
MethodDictionaryCollection

- Each object has a collection of superclasses (the superclasses chain).
Each class has one MethodDictionary.  Each object has the collection of all
the MethodDictionaries of all its superclasses.

Example:

Superclass3
  Superclass2
    Superclass1
      TheClass

Each of these classes has one MethodDictionary.  oneInstanceOfTheClass has
a collection of methods dictionaries like {TheClass methodDictionary.
Superclass1 methodDictionary. Superclass2 methodDictionary. Superclass3
methodDictionary}.

The collection CAN be shared between all instances of the class.  The
method dictionary of each class MUST be the same for any object that has
the class in the superclass-chain.

 testPriorSentence
    "unit test to show the prior sentence written in poor english"
    | allInstances |
    allInstances := Object allSubInstances.
    self
       should: [
          allInstances
             allSatisfy: [:eachInstance |
                | superclassesChain methodDictionariesChain |
                superclassesChain := eachInstance class withAllSuperclasses.
                methodDictionariesChain := superclassesChain
                         collect: [:eachClass | eachClass methodDictionary].

                eachInstance methodDictionaryCollection =
methodDictionariesChain]]

With this approach we have exactly the same behavior we have today. But...
we can put in the MethodDictionaryCollection one more entry for instance-
specific-behavior (or more than one to have super-instances a la Self).

The VM has to be modified to look over the MethodDictionaryCollection
instead of using the class.


The other change is to "hack" the VM to check is the
MethodDictionaryCollection is a real MethodDictionaryCollection.

- If it's a real one: The normal method look-up is used.

- If it is NOT a real MethodDictionaryCollection: The object (the one in
place of the MethodDictionaryCollection) is asked for the method with some
normal smalltalk message (example: #methodForSelector:andReceiver:).  Then,
the result of the prior message is "evaluated" with another normal message
(example: #evaluateOnReceiver:context:).

With these *relative* simple changes to the object struct and the VM, we
open the door to research a lot of alternatives:

- different methods lookups
- behaviour in object level
- different type of method activation (examples: accesors a la Self,
MethodComposites, pre and post conditiona a la Eiffel, etc)


Just my 2 cents,

Diego Gomez Deck


[*] Thanks to Alejandro Reimondo for infect me with these ideas!





More information about the Squeak-dev mailing list