Tony Mechelynck wrote: > On 23/06/08 19:28, Ben Schmidt wrote: >> Hi, Bram, >> >> Another oddity I've recently discovered is that str2nr won't accept an >> explicitly >> positive number, such as '+3'. >> >> This is unexpected. Would you be willing to adjust the behaviour? I can't >> think of >> any negative/compatibility-breaking side effects this would have, but I also >> don't >> know where the vim_str2nr function is used. >> >> The attached patch does the job. >> >> Cheers, >> >> Ben. > > In +3, + is a unary operator, which in this case doesn't change the > number 3 to which it is applied.
That's one interpretation. But it's equally valid to interpret +3 as a number. And since str2nr converts strings to Numbers, I feel it should accept such a number. > Maybe a note would be needed under ":help Number" to mention that +3 is > parsed as two tokens, viz. the unary operator + and the number 3 If this is to be fixed by documentation...which is a dumb idea in my opinion, as I can see no reason not to allow +3 to be a number (since + as an operator does nothing, and + as part of a number does nothing, it doesn't matter how it's interpreted, and from a human point of view, +3 is definitely a valid number) it should be documented at str2nr() since that is where it breaks. Ben. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---