On Tue, 2004-08-24 at 15:55, Adam D. Lopresto wrote:
> On Tue, 24 Aug 2004, Aaron Sherman wrote:

> > Yep, and since ~~ auto-topicalizes its lhs for its rhs, your binary ??
> > is all you need. I wish I'd seen your message before I sent my recent
> > one, as I would have just started from there.
> >
> > Precedence worries me a bit, since I don't know how ~~ and ?? would fit,
> > but it's certainly nice to have this construct use a generic Perl 6
> > operator like ~~ and not have to have any ternary constructs in the
> > language.
> 
> 
> My problem is that then you can't get to the original topic.  I think too much
> topic-clobbering will be confusing.
> 
> say chars($_) > 70 ~~ abbreviate($_) ?? $_;  #oops, prints the length

You don't HAVE to use auto-topicalization. You CAN always write it
long-hand if you find that confusing:

        for @words -> $word {
                given ($chars($word) > 70) -> $toolong {
                        say abbreviate($word) ?? $word;
                }
        }

But, I find:

        for @words -> $word {
                say $word ~~ abbreviate($word) ?? $word;
        }

much simpler! Overall, I would discourage the use of C<$_> as topic in
most situations. We spent so long in Perl 5 wanting the ability to
default to whatever variable we wanted, to keep using C<$_> in the
general case now that we have that is kind of a step backwards. I think
Perl 6 programmers are going to have to treat C<$_> as more of a
second-class citizen and rely more on named topics.

Either way, the core idea that the third expression in C<?:> in Perl 6
should be the current topic is, I think, well worth using.

-- 
â 781-324-3772
â [EMAIL PROTECTED]
â http://www.ajs.com/~ajs

Reply via email to