On Sun, Oct 16, 2016 at 12:44 PM, CodeDmitry <dimamakh...@gmail.com> wrote:
> I understand that it is a single message send, but to know how to handle the
> message at runtime, the parser needs to somehow determine where the
> implementation of that message is. It must do a lookup based on multiple
> keys(at, and put),

This is wrong :)
it is only one key #at:put:

Define a method....
    a := Array new: 1.
    a at: 1 put: 'Hello, World'.

Then in the method pane, right-click and choose Inspect Method,
then look at the [Bytecodes] tab.
You'll see "28 <C1> send: at:put:"
So the parser has already done its part compiling the source code to
bytecode and plays no further part in looking up which implementation
method to execute in response to the message.  That is done by the VM
when the message is sent.  If you look at the chart at the top of [1],
you'll see #interpret calls #dispatchIn:On: which calls
#commonOrdinarySend:.   This calls #internalFindNewMethodOrdinary
which starts the actual method lookup by the VM.  To review these
methods you need to load the VMMaker package, which the instructions
at [2] will do for you.

[1] http://forum.world.st/CogVM-Execution-Flow-td4900675.html
[2] https://github.com/pharo-project/pharo-vm

cheers -ben

which is really confusing. "methods" are easy to look up
> because they only have one name, but messages have one name which is split
> amongst each argument.
> Simple concatenation does not make sense, since {at: x, put: y} and {a: x,
> tput: y} are different messages.
> The only way I can think of this being implemented "easily" is by storing a
> table of entries {num_args, arg_names, impl_ref}, and then have the function
> "send" do a linear search over this table until it finds an entry with
> num_args = 2, each arg_name matching the argument name keys in order, and
> then calling the impl_ref with the array of values without the names.
> I'm wondering if there is a way to do this without having to loop over every
> single message the object has, then every message its' parent object has,
> and so on, just to find which function you actually want to call.
> --
> View this message in context: 
> http://forum.world.st/How-do-Smalltalk-disambiguate-messages-tp4918946p4918948.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to