On Mon, Dec 06, 2004 at 10:38:10AM -0500, Austin Hastings wrote:
: Two more issues: idiom, and topification
: 
: ===== Topification:
: 
: There are cases in P5 when I *don't* want
: 
:  while (<>) {...}
: 
: but prefer
: 
:  while ($input = <>) {...}
: 
: so that I can have something else be the topic. Every example to date 
: has used C<for>:
: 
:  for .lines {...}
: 
: but that sets the topic. I'm a little fuzzy on this, but doesn't C<for> 
: play topic games even in this?
: 
:  for .lines -> $input { ... $input ... }
: 
: That is, even though "$_" remains unaffected, doesn't this affect 
: smartmatch etc.?

Currently it does.  There have been some rumblings in the design team
that maybe it shouldn't.  But it occurs to me that this might be another
spot to have our cake and eat it to.  We could say that

    for @foo -> $input { ... $input ... }

doesn't set the topic in the block by default.  However, methods do set
the topic (though there have been rumblings about that too).  So we could
simply say that pointy subs can also be pointy methods if you specify
an invocant:

    for @foo -> $input: { ... $input and $_ ... }

I think I like that, but it needs to be thunk about some more.  The downside
is that it's rather subtle.  The upside is that it falls out of existing
rules, and lets -> map more naturally in the way people expect.  I don't
think people will naturally expect -> to clobber $_.

Larry

Reply via email to