# New Ticket Created by  Klaas-Jan Stol 
# Please include the string:  [perl #57656]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57656 >


hi,

the "." has different meanings in PIR:

1. to separate object and method in a method call, like:

 foo.bar()

2. to concatenate strings:

 $S0 = "hi" . "there"

Now, while implementing this is not really a problem (it has been done
already), it does introduce some ambiguity.
This case makes that clear:

.sub main
    .local pmc foo
    $P0 = newclass "Foo"

    foo = new "Foo"
    foo . "bar"()
.end

.namespace ["Foo"]
.sub bar :method
    print "foo::bar\n"
.end



Running this code will result in an error:

$ ./parrot foo.pir
error:imcc:syntax error, unexpected CONCAT, expecting '(' (' . ')
        in file 'foo.pir' line 8

in general, whitespace is not significant in PIR, but in the case of the dot
it is.
(a dot with whitespace on both sides is tokenized as the concat operator)

My proposal would be to change the concatenate dot into "..", which looks
like it, but is more explicit, and will prevent such mistakes.
I'm also open to other suggestions (I've thought of ~, a la NQP/Perl 6, but
was not sure whether that would introduce other ambiguities; an alternative
might be interesting in case we ever want to resurrect the slicing syntax
using the ".." ).
(FYI, the ".." is the concatenation operator in Lua)

Please note that it's not my intention to change the whole PIR language into
what suits me (given the number of proposals for change in PIR), but over
time I'm running into these issues, and we're currently still in an easy
position to fix this. Frankly, I consider this proposal not the best I've
had, but I decided to send it out anyway.

comments welcome,
kjs

Reply via email to