Damian Conway <damian@conway.org> wrote: :Abigail observed: :> Besides, if someone were to use: :> :> $var ~~ $x; :> :> and $x could be a number or a regexp, but in one of the runs gets served :> the above warning (because this time, the code path has printed out $x), :> and changes it to: :> :> $var ~~ 0 + $x; :> :> it ain't going to work well in case $x is a regexp (or a coderef, or has :> overloaded ~~ but not +, or has overloaded +, or several other cases), is it? : :You're right. That's a problem. That's *the* problem. : :The correct long-term solution is for Perl to know what type a scalar :actually contains, and not to subsequently lose that knowledge merely :because of internal side-effects and optimizations of the implementation. :-( This is the bit I'm really not convinced about. I feel there is a significant difference between the language that has this: my($value) = ($line =~ /value=(\d+)/); # yay, we got a number and the one that has this: my($value) = ($line =~ /value=(\d+)/); # yay, we got a number $value += 0; # RT#314159: oops, *now* we got a number The first of these expresses much that to me seems intrinsic to what perl is. The second seems to throw out the DWIM with the bathwater. HugoThread Previous | Thread Next