syntax ambiguities.

Jecel Assumpcao Jr jecel at
Mon Sep 2 18:42:55 UTC 1996

Pierre De Pascale wrote:
> Hello selfer's,
> I have read the self 3.0 reference manual and stopped at the appendix
> where the syntax of the self language was presented. In particular the
> syntax presented is highly ambiguous, but a small foot-note says that
> the ambiguities are resolved using standard precedence techniques.

I think it only means that precendece is used to decide on
how to parse unary, keyword and binary messages. Other
ambiguaties are handled in more confusing ways :-)

Take a look at how the parser decides if a '-' is a binary
operator or part of a negative number, for example.

> But I still got some problems:
> 1. when you initialize a slot. How do you determine if it is a method
> or a simple value ? for example:
>         (| mySlot = ( randomNumber ) |)
> what is the meaning of the mySlot initialization: do I initialize
> mySlot with a one-time call to randomNumber (i.e. mySlot is a value
> slot) or mySlot returns a new randomNumber everytime (i.e mySlot is a
> method) ?

In this case it will always be a method that returns a random
number. The parser will try to see this as a method slot first
and then as a constant slot with an initializer.

I don't have a Self 4 implementation handy, but I'll bet you
can make it parse the other way by doing:

         (| mySlot = ( randomNumber ) + 0 |)

> 2. a same kind of ambiguities appears in expressions: what is the
> meaning of this expression ?
>         aVariable: ( randomNumber )
> Do I initialize aVariable with one random number, in this case () are
> for precedence reason, or with the object "(randomNumber)", in this
> case a method object.

In Self 1.0 this was an inner method. It was an actual method
object but it executed "inside" the outer method like a block.
The result was exactly the same as if you had parsed this as
an expression, of course, so it was dropped in Self 2.0. So
once paranthesis always indicated an object, but now we
have your "ambiguities".

In the above code you couldn't have a literal method being
assigned to aVariable because you can only manipulate
methods indirectly through mirrors.

> 3. how can you detect a resend ? for example:
>         myResendSlot.resendMethod
> This could be interpreted as a directed resend or two expressions
> consisting of two method sends, one myResendSlot and one
> resendMethod. How do you make the difference ? is there a runtime
> decision of the meaning ?

To interpret this as two separate expressions, you would
have to have a space after the period. Another place in
the syntax where spaces are used to solve ambiguities is
when declaring an empty list of slots:

    ( | | doSomthingStupid )  "ok"

    ( || doSomethingReallyStupid ) "means self OR do..."

Note that this use of space means it is impossible to
really separate the scanner from the parser :-(

> It may be possible that those issues were already discussed in this
> mailing list. Since I subscribed only lately I was lazy enough not to
> check the past issues. Just tell me if I need to kick myself :^)

The general problem of syntax has been discussed, but not
these particular details.

BTW. it would be better for you to experiment a little
rather than believing anything I just wrote...
-----=============( Jecel Mattos de Assumpcao Jr )===========----- | mailto:jecel at

More information about the Self-interest mailing list