On 5/12/05, Jonathan Scott Duff <[EMAIL PROTECTED]> wrote: > 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. > > That's some subtle evil. > > > My suggestion is that a match object in numeric context is the > > same as evaluating its string value in a numeric context. > > While I agree that this would be the right behavior it still feels > special-casey, hackish and wrong. > > If, as an optimization, you could tell PGE that you didn't need Match > objects and only cared about the string results of your captures, that > might be better. For instance, > > if 'localhost:80' ~~ m:s/^(.+)\:(\d+)$/ { > my $socket = connect($0, $1); > } > :s for :string (assuming that hasn't already been taken)
What about the fact that anything matching (\d+) is going to be an Int and anything matching (.+) is going to be a String, and so forth. There is sufficient information in the regex for P6 to know that $0 should smart-convert into a String and $1 should smart-convert into a Int. Can't we just do that? Rob