On Thu, Feb 28, 2002 at 03:17:19PM -0600, Garrett Goebel wrote:
> I do worry that as Perl grows richer, so does the need for underlying
> consistency and simplicity. 

You're not alone in that.

> I guess it is all about seeking the correct balance. And that is
> something Larry and the Perl community have a pretty good track record
> with so far.

As Damian is so fond of saying, "Trust Larry".

> And until now I was safe assuming the one fixed variable $_ as the
> default. Now there is the one special case C<when> where I need to
> know the difference. And nothing visible in the code to remind me that
> its there. Difficult to teach, yet another thing to remember, and a
> potential nuisance to debug. 

It will certainly need to be taught. But I don't think it's difficult to
teach. The remembering and debugging also stem from teaching. 

> Though I guess I'm getting an inkling of how a year from now it'll be
> yet another tool who's usefulness I'll take for granted.

If you start to like the idea more as you understand it more, it's a
good sign that others will too. That's the mark of a Good Idea(tm).

> I wonder if this:
> 
> for 'foo' {
>   given 'food' -> $x {
>     print when /$_/
>   }
> }
> 
> would print "food"?

It should print "foo".

> And makes me wonder if:
> 
> for 'foo' {
>   given 'food' -> {
>     print when /$_/
>   }
> }
> 
> Wouldn't be a useful syntax for specifying that the switch value can only be
> seen by the case value? I.e. No don't inject 'food' as a lexical, and don't
> associate it with the fixed default variable $_ either...

Oh, you mean like CATCH? That is, unless CATCH also implicitly aliases
$_ to $!. It doesn't seem like it would need to, I can even think of
some reasons you wouldn't want it to, but it might for the sake of
consistency.

But, it seems like you might not want to leave yourself with no way to
get to the value. Hmmm...

> > But I do think it's worth it. Despite the details of consistency and
> > clarity that still need to be worked out, it's a very dwim change that
> > is a big part of the elegance of the switch statement.
> 
> Exactly. And thanks to multiple readings of Apocalypse 4, and your
> explanations... I'm pretty sure I'm getting it. I might even be a little
> more comfortable with it. 
 
Excellent! 
<buttons up school-marmish coat, picks up carpet-bag and umbrella with
parrot-head handle and floats off into the clouds> ;)

> I certainly hope the idea of the topic, topicalizers, and topicalizees as
> separate from the fixed $_ default variable gets pounded out quite throughly
> in the "What's New?" section of the Perl6 documentation. 

You can bet on it. I know one person who'll volunteer if no-one else
does...

Allison

Reply via email to