develooper Front page | perl.perl6.language | Postings from April 2006

Re: foo..bar or long dot and the range operator

Thread Previous
From:
Damian Conway
Date:
April 12, 2006 15:57
Subject:
Re: foo..bar or long dot and the range operator
Message ID:
443D85C1.4050407@conway.org
TSA wrote:

 > I *still* don't understand the problem this long dot is trying
 > to solve.

It's trying to solve the fundamental ambiguity of:

     foo .bar

Which might be:

     foo().bar

or might be:

     foo(.bar)

The way we solved it is by saying that, anywhere a term is expected, a 
sequence matching:

     /\s+ \. [<ident>|<brackets>]/

is always a unary dot method call.

The reason we chose that is because we think that things like this:

     method describe {
         say .name;
         say .rank;
         say .serial_num;
     }

and this:

     given %data {
         .<name> = join .<sep>, ucfirst .<first>, uc .<family>
     }

will be common. And that it's much easier to understand such constructs if a 
"gappy dot" *always* means unary dot, regardless of what preceded it.

That leaves a problem for people who want to line up method calls, or cascade 
them over multiple lines. So we need a way to indicate that a "gap-dot" 
doesn't mean unary method call. Which means we need a way to prevent perl6 
from expecting a term, where a term is normally expected. Which we chose to do 
by providing a postfix that indicates "more expression to come yet" or "don't 
switch back to expecting a term here".

And the postfix Larry decided upon (rightly, I believe) was dot.

Damian

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About