I am trying to do a JavaScript experiment to make Objects behave like
Smalltalk objects.

example:
    
    "reminder: Smalltalk arrays start at 1."
    |arr|
    a := Array new: 1.
    a at: 1 put: 'Hello, World'. 

Here, the Smalltalk array has a message "at: index put: value" which is
defined many layers of prototype chaining down, at Object in category
accessing.

However there are many messages on the way traversing the prototype chain
that start with "at:", such as(SequenceableCollection) "at: x ifAbsent: y",
"at: x incrementBy: y".

How does Smalltalk tell which message is which? Does it merge the messages
into a single message such as "at: x put: y" to "atPut(x, y)" at some point? 

Without knowing this, I have to traverse the whole call chain and check
whether each argument is called in a specific way, which is incredibly
expensive. If there was a single name such as "atPut" I can easily just do a
dictionary lookup for this name and get it at O(1).

Does Smalltalk actually store each message?



--
View this message in context: 
http://forum.world.st/How-do-Smalltalk-disambiguate-messages-tp4918946.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to