On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote:
: On Fri, May 13, 2005 at 03:23:20AM +0800, Autrijus Tang wrote:
: > Is it really intended that we get into habit of writing this?
: > 
: >     if 'localhost:80' ~~ /^(.+)\:(\d+)$/ {
: >     my $socket = connect(~$0, +$1);
: >     }
: > 
: > It looks... weird. :)
: 
: And it would have to be
: 
:      if 'localhost:80' ~~ /^(.+)\:(\d+)$/ {
:       my $socket = connect(~$0, ~$1);
:      }
: 
: because +$1 still evaluates to 1.  (The ~ in front of $0 is 
: probably optional.)
: 
: My suggestion is that a match object in numeric context is the
: same as evaluating its string value in a numeric context.  If
: we need a way to find out the number of match repetitions (what
: the numeric context was intended to provide), it might be better
: done with an explicit C<.matchcount> method or something like that.

I think we already said something like that once some number of
months ago.  +$1 simply has to be the numeric value of the match.
It's not as much of a problem as a Perl 5 programmer might think,
since ?$1 is still true even if +$1 is 0.  Anyway, while we could have
a method for the .matchcount, +$1[] should work fine too.  And maybe
even [EMAIL PROTECTED], presuming that "a match object can function as an array"
actually means "a match object knows when it's being asked to supply
an array reference".

Actually, it's not clear to me offhand why @1 shouldn't mean $1[]
and %1 shouldn't mean $1{}.

Larry

Reply via email to