On Mon, May 14, 2007 at 10:48:34PM -0700, Garrett Cooper wrote:
: No one mentioned that if it wasn't for sigils, many strings would be 
: increased, length-wise, to do operator concatentation. If it wasn't for 
: that then simple string insertions couldn't be used.

Well, except you can interpolate in Perl 6 with bare closures, so

    say "answer = {foo}"

wouldn't be so bad.

: The only thing I hate about Perl with required formatting is the silly 
: braces. If it's one line and separated by visible whitespace, why is the 
: only option available to me the
: 
:       statement_1 if(statement_2);
: 
: or
: 
:       statement_1 unless(statement_2);
: 
: syntax? Seems less readable than:
: 
:       if(statement_2)
:               statement_1
: 
: or
: 
:       unless(statement_2)
:               statement_1

That has been a not-infrequent complaint about Perl from people coming
from a C-ish background.  However, what we discovered with the Perl 6
design was that it was not, in fact, the braces that were silly, but
the parentheses.  The braces consistently represent a closure in Perl 6,
even in control constructs, which are not special-cased as in C and Perl 5.
But by taking that approach we can get rid of the parens that are doing
only syntactic work without carrying any semantic weight.  So Perl 6 ends
up with the one-liner:

    if statement_2 { statement_1 }

and that's no more characters than your parentesized version.

Now you might think that the curlies are still useless there, but the
fact that it's a closure means you can capture the value of the control
condition if you like.  This would be rare with an if, but with other
control flow structures it's quite common.  In particular this very
common construct:

    for 1..100 -> $i { say $i }

Since -> is just a built-in way of writing an anonymous sub with
arguments, there's no need to invent special syntax for loop variables!

And when you say

    for 1..100 { say $_ }

you're still logically calling an anonymous sub with a single parameter
called $_.  I freely admit that the use of braces in C and Perl 5 is
silly, but the braces in Perl 6 are about as far from silly as you
can get.

: The only legitimacy for the first set of formats would be if in fact you 
: were reading off the logic statement in a left-to-right language. But 
: then again many languages don't follow that convention (Japanese, 
: Korean, etc etc for instance).

Oddly, the statement modifier is borrowed directly from English.

: The same opinion goes for all loops, except the
: 
:       do { statement } ( { while, until } );
: 
: variety.

That particular construct comprises several additional cans of worms.  :)

Larry

Reply via email to