pp_negate
I see three problems with this function: 1. [#36674] -undef results in -0.0 rather than the expected 0. This is probably easy to fix, but I don't know if undef is the only value for which (!SvIOKp(sv) !SvNOKp(sv) !SvPOKp(sv)). 2. [#36675] Strings starting with '-' or '+' are treaded as strings, even when they represent numbers. Now I doubt this should be changed, but at least it should be clearly documented in perlop and probably perltrap. (imagine someone extracts numbers with a regular expression or split, and expects -100 to be treated the same way as 100) 3. There is some special treating of UTF-8 strings: they can be prefixed with '-' even when they don't start with an identifier first character. I was unable to provoke this behavior in practice, who knows how to do that?
Re: pp_negate
On Fri, Jul 29, 2005 at 08:36:10AM +0200, Piotr Fusik wrote: 2. [#36675] Strings starting with '-' or '+' are treaded as strings, even when they represent numbers. Now I doubt this should be changed, but at least it should be clearly documented in perlop and probably perltrap. (imagine someone extracts numbers with a regular expression or split, and expects -100 to be treated the same way as 100) I guess the upshot of this is: $ perl -wle '$f = -100; print -$f' +100 $ perl -wle '$f = -100; print -$f' 100 -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern Just call me 'Moron Sugar'. http://www.somethingpositive.net/sp05182002.shtml
Re: pp_negate
-BEGIN PGP SIGNED MESSAGE- Moin, Michael G Schwern [EMAIL PROTECTED] wrote: On Fri, Jul 29, 2005 at 08:36:10AM +0200, Piotr Fusik wrote: 2. [#36675] Strings starting with '-' or '+' are treaded as strings, even when they represent numbers. Now I doubt this should be changed, but at least it should be clearly documented in perlop and probably perltrap. (imagine someone extracts numbers with a regular expression or split, and expects -100 to be treated the same way as 100) I guess the upshot of this is: $ perl -wle '$f = -100; print -$f' +100 $ perl -wle '$f = -100; print -$f' 100 The first one looks wrong to me: # perl -wle '$f = -fo; print -$f' +fo # perl -wle '$f = -NaN; print -$f' +NaN Ugh. You learn to find some dusted, obscure Perl corner every day... Best wishes, Tels - -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern Just call me 'Moron Sugar'. http://www.somethingpositive.net/sp05182002.shtml - -- Signed on Fri Jul 29 12:44:42 2005 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. Ich bin mit der Gesamtsituation unzufrieden! -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (GNU/Linux) iQEVAwUBQuoJHXcLPEOTuEwVAQEZ0gf+MXC+1uRx17o9qQV3vHB/OK/MfCLxuKLf sBXMvHvc5GDHGzDhM296rdCX82fY0i8eOJgQo0YKfFTAjZLZOkUxEOc2fHdyr3Kh ZZ3Zxt/GMkcR/fpTzlUemPk2PZELUE3Pb+pUieTvDzmS0hGrqvelyDwurUSTL9fK obCsedolBvjur85tjeS4MWWOQ+xbgWWBF/TOupYVIasue7jjMXxKX+yaYjcIxzlA llFUWqH2M21iz6IFi0adL9gWekgVgG54n+r2+Us1NXvZVpypHixSN/0SmoC+5ACL M0ZnC71HQsnVZUEQOwrktUQxy1oWUYUW2nFxlrHW0pKvjGChHvo/Wg== =WUUr -END PGP SIGNATURE-
Re: Re: pp_negate
The first one looks wrong to me: # perl -wle \'$f = -fo; print -$f\' +fo # perl -wle \'$f = -NaN; print -$f\' +NaN Ugh. You learn to find some dusted, obscure Perl corner every day... This behavior is clearly documented in perlop: if the string starts with a plus or minus, a string starting with the opposite sign is returned I'm more interested in the problems 1 and 3.