Rich Howe wrote:

> > One thing that won't work (even though it was not a good idea anyway):
> > If code would use manual IDs of 1000 and higher, assuming that matches
> > without a match ID would never reach 1000.
> > This breaks, because your proposal sets the next_match_id to one more
> > than the manual ID, thus they will very soon collide.
> 
> My proposal always sets next_match_id to be maximum of IDs + 1
> even if it is manual or not, so nex_match_id will not collide.
> For example:
>         firstly
>         matchaddpos('ToDo', [[1]], 10) returns 4
>         then
>         matchaddpos('ToDo', [[1]], 10, 1000) returns 1000
>         then
>         matchaddpos('ToDo', [[1]], 10) returns 1001

The problem is that if someone uses a manual ID of 1000, then most
likely it will use 1001 next.  That clashes with the automatically
assigned ID.

>         then
>         matchaddpos('ToDo', [[1]], 10) returns 1002
>         then
>         matchaddpos('ToDo', [[1]], 10, 500) returns 500
>         then
>         matchaddpos('ToDo', [[1]], 10) returns 1003
>         then
>         matchaddpos('ToDo', [[1]], 10, 2000) returns 2000
>         then
>         matchaddpos('ToDo', [[1]], 10) returns 2001
> 
> One of concerns in my proposal is that once a manual ID is too big
> nex_match_id could eventually become integer overflow.

We should take care of that as well, although I would expect in most
cases all matches to be cleared, in which case we can reset the max ID.

> Please let me know if there is still a chance to collide the IDs.

As mentioned above.  I'm not sure how important this is.  One might just
use the same manual ID over and over again, and not increment it.

Also, you need to make sure that setmatches() restores the next ID.

-- 
"Women marry men hoping they will change. Men marry women hoping
they will not. So each is inevitably disappointed."
 - Einstein

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui