[self-interest] Re: Self bytecodes

Jecel Assumpcao Jr jecel at lsi.usp.br
Mon May 31 21:08:38 UTC 1999

> It all seems fine, but I donĀ“t understand something seemingly
> straightforward: knowing that in a send the receiver and arguments are
> popped off stack and the result is pushed onto stack, how is the number
> of arguments of a send determined, so that my interpreter could know how
> many pops it should make? It seems that in the fast_compiler, when the
> machine code for a send is generated, the information of number of
> arguments is kept somewhere. Where?

You can just count the number of ':' characters in the selector name,
and that is the number of arguments. Except that if the selector name
is composed of special characters, then we have a binary selector and
there is one argument.

Testing this at every message send is *very* inefficient - the
Smalltalk bytecodes encode the number of arguments in the send
bytecode itself. But since the Self bytecodes were meant to be
compiled away, this wasn't considered a problem.

For an interpreter, there isn't a good solution if you are going
to use a standard Self world. If you don't mind creating your own,
slightly different, world you could separate canonical strings
representing selectors into different "types". One way to do this
would be to add a constant slot indicating the number of arguments
when you canonicalize a string. That way, 'last' would have a
constant slot with the value 0, while for 'between:And:' that
slot's value would be 2. This slot would always be in the same
place in the string's map (if you don't make any other changes)
so your interpreter can easily access it.

-- Jecel


eGroups.com home: http://www.egroups.com/group/self-interest
http://www.egroups.com - Simplifying group communications

More information about the Self-interest mailing list