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

Re: or long dot and the range operator

Thread Previous
Damian Conway
April 12, 2006 15:57
Re: or long dot and the range operator
Message ID:
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:


or might be:


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.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About