[self-interest] Method are not objects?

Jecel Assumpcao Jr jecel at merlintec.com
Thu Oct 12 19:59:44 UTC 2000

> In the last few days I played with Self4 on a sparc machine and found
> some strange
> things:
> VM# ( | a | 'ciao' )
> 'ciao' <3>: ( | parent* = <4>. | byte array: {99, 105, 97, 111} )  
> it seems that the parser does not parse this construct as an "object
> with code", but
> instead it evaluates it, forgetting the "| a |" .

It is exactly the same as if you had tried

    [ | a | 'ciao' ] value

> This behaviour is not consistent with ( | m = ( | a | 'ciao' ) | )
> where it is parsed as a method (object with code).

It *was* parsed as a method, but then executed automatically.

> I know that mirrors are used to handle methods but this why not allow
> creating method literals ?

Self defines that any reference to a method object causes its execution
directly. This allows you to send 'm' to your second object and get
'ciao' as the answer instead of the method object itself. The problem
with this is that you can then never reference any method directly, but
only through a mirror object.

The alternative would be to allow methods to be referenced and stored
in slots like any normal object, but have a special type of "auto
evaluate" slots where you could store methods and have them behave the
way they do now in regular constant slots.

Self's designers simply felt that the "special slots" solution was

-- Jecel

More information about the Self-interest mailing list