On 11/23/05, Luke Palmer <[EMAIL PROTECTED]> wrote:
> On 11/23/05, Rob Kinyon <[EMAIL PROTECTED]> wrote:
> > On 11/22/05, Larry Wall <[EMAIL PROTECTED]> wrote:
> > >
> > >     for ^5 { say }  # 0, 1, 2, 3, 4
> >
> > I read this and I'm trying to figure out why P6 needs a unary operator
> > for something that is an additional character written the more legible
> > way.
>
> Huh?  Are you saying that 0..^5 is one more character than ^5?

No, I'm saying that 0..$n-1 is one more character than 0..^$n. And, it
has the added benefit of being legible to people who don't know the
ins and outs of every single operator of the 60+ P6 looks like it will
have.

> In any case, I'm not sure that this unary helps readability, or that I
> like it all that much, but I can say that it's damned useful.  I use
> ranges of the form 0..$n-1 more than any other range, by a very long
> shot.

I don't use 0..$n-1 very often. I use 0..$#arr most often. But,
frankly, I don't use ranges very much at all. I try to avoid parallel
arrays, which is really the only time I can see using a range like
that. I try and let the datastructure (IO handle, array, etc) control
when it's done.

> > To me, ^ indicates XOR, so unary ^ should really be the bit-flip
> > of the operand.
>
> Except in Perl 6, XOR is spelled +^ or ~^, and ^ is Junctive one().
> So it seems that ^$x should be one($x).  But that's an entirely
> useless, trivial junction, so it makes sense to steal the syntax for
> something else.

Here's an issue - if ^$x would be one($x), then what will [EMAIL PROTECTED] be? 
To
me, that seems like it should be one(@x), which is entirely useful.
Except, if I try and use it as [EMAIL PROTECTED] (which, to me, would be 
useful).
So, now, is it 0..one(@x) or [EMAIL PROTECTED]

Rob

Reply via email to