Glenn Linderman wrote: > On the other hand, there is a case to be made that any form of number that > might get printed by perl's unformatted i.e. > > print 0+$var > > should be reconvertible back to a string via implicit numeric conversions of > strings. I think the only thing that would affect would be imaginary numbers, > if supported, and if enabled in the lexical scope of the conversion.
Yes, good point. +"$x" should be still the same as $x, otherwise any implicit stringification could cause a lot of troubles. > It would certainly seem reasonable to have a warning for numeric conversion of > strings containing trailing garbage. At least under some level of strict-ness. There is already such warning. But I think it should also be way to get NaN in such cases. > Or, perhaps a collection of string methods could be useful... > > $string.as_num # do the Perl usual implicit string conversion > $string.is_num # same as as_num, but undef if trailing garbage > $string.as_code_num # convert all numeric literals legal in code > $string.is_code_num # same as as_ext_num, but undef if garbage That's definitely a good idea to have such methods but there also have to be way to define what to do with +$string. I think having some levels of that would be the best idea, with the lowest level even "5E3" is converted to 5 and with the highest "pi*(2k+3iM)/12_650**1e-1" is converted to whatever it is, but the default is somewhere in the middle, close to that what we have now. That seems to be the only reasonable way. And besides, there could be some level of strictness where "123foo" is NaN (whatever it will mean), not 123, where not the whole string is valid as number. (now there's a warning, but there should be warning by default and NaN if wanted)). - RaFaL Pocztarski, [EMAIL PROTECTED]