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

Fw: ( Re: A shorter long dot

Thread Next
April 29, 2006 09:00
Fw: ( Re: A shorter long dot
Message ID:
I get a message like this for every message that I send to this list.
Trying to contact did not result in response or change.

Any ideas?

----- Forwarded message from sbc sbc <> -----

From: sbc sbc <>
Date: Sat, 29 Apr 2006 08:31:24 -0700 (PDT)
Subject: Re: A shorter long dot

Testing with sbc30k

 [] wrote:
> 16:50 < audreyt> Juerd: write to p6l and explain the ".." conflict,

The current long dot consists of a dot, then whitespace, and then
another dot. The whitespace is mandatory, which makes the construct at
least three characters long. Tripling the length of an operator, just to
make it alignable, is quite a lot.


    $fooz. .foo();  # doesn't line up, so we have to change the
                    # *previous* line!
    $foo. .foo();   # this lines up again.

So we use:

    $xyzzy. .foo();
    $fooz.  .foo();
    $foo.   .foo();

which is ugly and feels bad. It feels bad, because we're adding much
more whitespace (two character positions in total) than we had to
bridge. And it's a lot of work (many, many keystrokes!) to go back and
change something.

However, the whitespace in between cannot simply be made optional, as
then it would clash with the range operator. As ranges are even more
important than a sane "long dot" solution, the long dot had to change.

Larry indicated that changing the long dot would have to involve
changing the first character. The only feasible solution in the "tiny
glyphs" section was the backtick. I refrain from explaining why that
will widely be considered a bad idea.

Audrey cleverly suggested that changing the second character would also
work, and that has many more glyphs available. So she came up with

> and propose ".:" as a solution,

That's right, dot-colon. There are more glyphs available, but none of
them is nice like this. The basis is in regexes, where a colon means you
commit to have parsed the left side of the colon. That's how the colon
already reads in the indirect object notation, and the colon in
${...} can already be read.

So the actual solution is to make the method call operator not ".", but
".:". Of course, a lone "." still works and is the recommended style for
all simple method calls that don't have to be lined up. You can also
explain it as "." still being the base operator, where ".:" is a special
form. Whatever you like best :)

> and ". :" as an extension, 

Of course, it wouldn't be a solution to the long dot problem if it
didn't allow an arbitrary amount of whitespace in between. 

So, obviously, it does allow lots of whitespace in between. And, of
course, comments. If you really hate your future maintainer, you could
even put some POD in between.

    $foo. :foo();

Or, if you prefer:

    $fooz. :foo();
    $foo.  :foo();

Or, if you actually LIKE the extra whitespace that the current long dot

    $xyzzy. :foo();
    $fooz.  :foo();
    $foo.   :foo();

> and ". +" as an generalization,

Of course, this works nicely with the operators it was inspired by, that
were also inspired by regex postfix operators: ".*", ".+" and ".?". They
can also contain whitespace in our proposal.

The dot-colon fixes another problem too. You couldn't line them up


----- End forwarded message -----


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