Simon Cozens writes:
> [EMAIL PROTECTED] (Luke Palmer) writes:
> > I was reading the most recent article on perl.com, and a code segment
> > reminded me of something I see rather often in code that I don't like.
> 
> The code in question got me thinking too; I wanted to find a cleaner
> way to write it, but didn't see one.
> 
> > So, in Perl's postmodern tradition, I think we should steal that idea.
> 
> I agree, but (as usual) would like to consider whether there's a way
> to solve a general problem rather than solving a specific problem by
> throwing additional syntax at it. (which sadly seems to be fast becoming
> the Perl 6 way)

Well... it is and isn't.  At first sight, it makes the language look
huge, the parser complex, a lot of syntax to master, etc.  It also seems
to me that there is little discrimination when adding new syntax. 

But I've come to look at it another way.  Perl 6 is doing something
(many things, really) that no other language has done before: making it
very easy to add new syntax to the language.

So modules that introduce new concepts into the language can add new
syntax for them without working with (ugh) a source filter.  And some of
these new syntaxes in the "core" language will actually be in standard
modules, if they're not commonly used.  Just like traits.

But even when they're not, Perl is a generic, multiparadigm language.
It covers and supports many concepts, and new concepts grafted onto an
existing but unfit syntax make things harder.  Humans are pretty good at
syntax.  Many times mathematicians make up new syntax when they
introduce a new concept: making it easier to think about, and easier to
recognize.

I'll also point out that FINISH isn't really extra syntax, just extra
vocabulary.

> Given that we've introduced the concept of "if" having a return status:
> 
>   my $result = if ($a) { $a } else { $b };

Ack!  We have?  It does make sense if we want to be able to implement
C<if> as a regular sub... I guess.  Yuck.

> Then why not extend this concept and have a return status from other
> control structures?
> 
>   for 0..6 -> $t { 
>     last if abs(@new[$t] - @new[$t+1]) > 3;
>   } or push @moves: [$i, $j];
> 
> Of course, these things have consequences; I'm not sure whether we really
> want people saying
> 
>   push @moves:[$i, $j] unless last if abs(@[EMAIL PROTECTED])>3 for 0..6;

That's illegal anyway.  Can't chain statement modifiers :-)

But a close relative would be possible:

push @moves: [$i, $j] unless for 0..6 { last if abs(@[EMAIL PROTECTED]) > 3 }

Yeah, how about no.  :-)

Luke

Reply via email to