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.

eval('+3') gives the desired result, 3

Similarly, eval('--3') gives 3, changing the sign of the number -3 by 
means of the unary - operator. (-3 is parsed as a single token, as can 
be seen from the fact that str2nr('-3') == 3).

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


Best regards,
Tony.
-- 
"Even the best of friends cannot attend each other's funeral."
                -- Kehlog Albran, "The Profit"

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui