Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Bram Moolenaar
> Sorry but, > Out of well indexing, > which is faster ? > > 1) indexing by bytes -> legacy > 2) indexing by characters -> vim9script Indexing by bytes can be faster. But the difference is probably small, the computation of the index probably matters more. You'll have to try it out to know

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Bram Moolenaar
> On 2023-06-03, Bram Moolenaar wrote: > > > >> Legacy Vim script: > >> > >> let text = 'àbc' > >> echo text[2] > >> > >> Result: 'b' > >> > >> Vim 9 script: > >> > >> const text = 'àbc' > >> echo text[2] > >> > >> Result: 'c' > >> > >> Is the different behavior (counting chars

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread N i c o l a s
Hi Bram, Sorry but, Out of well indexing, which is faster ? 1) indexing by bytes -> legacy 2) indexing by characters -> vim9script Thank you for your answer. Nicolas ** Le samedi 3 juin 2023 à 13:12:53 UTC+2, Bram Moolenaar a écrit : > > > Legacy Vim script: > > > > let text = 'àbc' > > echo

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Lifepillar wrote: >> Yes, in Vim9 script the index is in characters. In legacy script it is >> in bytes. >> >> The help for this doesn't have it's own tag, I'll add one. >> You can find it above ":help vim9-gotchas". > > I was expecting to find it under `:help vim9-differences`,

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Bram Moolenaar wrote: > >> Legacy Vim script: >> >> let text = 'àbc' >> echo text[2] >> >> Result: 'b' >> >> Vim 9 script: >> >> const text = 'àbc' >> echo text[2] >> >> Result: 'c' >> >> Is the different behavior (counting chars vs bytes?) intentional? > > Yes, in

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Bram Moolenaar
> Legacy Vim script: > > let text = 'àbc' > echo text[2] > > Result: 'b' > > Vim 9 script: > > const text = 'àbc' > echo text[2] > > Result: 'c' > > Is the different behavior (counting chars vs bytes?) intentional? Yes, in Vim9 script the index is in characters. In legacy

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Lifepillar wrote: > On 2023-06-03, Lifepillar wrote: > Mmh, even strpart(), which is supposed to count bytes, gives the same > result: Forget this: strpart() is fine. I have trouble just with indexing. Life. -- -- You received this message from the "vim_use" maillist. Do

Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Lifepillar wrote: > Legacy Vim script: > > let text = 'àbc' > echo text[2] > > Result: 'b' > > Vim 9 script: > > const text = 'àbc' > echo text[2] > > Result: 'c' > > Is the different behavior (counting chars vs bytes?) intentional? Mmh, even strpart(), which is

[vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
Legacy Vim script: let text = 'àbc' echo text[2] Result: 'b' Vim 9 script: const text = 'àbc' echo text[2] Result: 'c' Is the different behavior (counting chars vs bytes?) intentional? Thanks, Life. -- -- You received this message from the "vim_use" maillist. Do not