Klaas-Jan Stol wrote:

I'm sorry, but this is not the case. It is  in fact valid:
running:
==========
.sub main
    newclass $P0, "foo"
    $P1 = new "foo"
    $P1 .hi()  # note the space before the dot
    $P1. hi()  # note the space after the dot
.end

.namespace ["foo"]

.sub hi :method
    print "hi\n"
.end
==========
prints "hi\n" twice on my system and always has since I've worked on pir..

Ah, my code example had some other syntax error, which it was reporting as:

error:imcc:syntax error, unexpected DOT, expecting '(' ('.')
        in file 'method_call_whitespace.pir' line 5

Yes, those spaces do work.

And they shouldn't work.

(this is because, in imcc's lexer a '.' is always returned as DOT (for object/method separation) and a '.' is only returned as a concatenation operator iff it is surrounded by whitespace on both sides; the actual reg.expr for this in imcc.l is {WS}'.'{WS} )

Which explains why it was interpreting 'foo . "bar"()' as CONCAT, even though a concatenation operation makes absolutely no sense in that context.

In all, I don't want to make too big an issue out of this, just trying to clean up the peculiarities and have them documented :-)

Agreed, I've spent about all the time on it I'm willing to spend.

The valid syntaxes containing '.' are:

<var>.<method>(<args>)        # method call
<var> = <var/val> . <var/val> # concatenation
<var> .= <var/val>            # concatenation

Anything we can do to tighten the implementation and allow *only* those three is progress. But, it may just wait until the next PIR implementation.

Allison

Reply via email to