This doesn't produce an error. Should it?

   const c1 = 3
   unlockvar c1

Of course, there is an error on an attempt to modify c1.

I was wondering about const optimizations; figured now's not the time to mention it. Then saw that "len('string')" would be done at compile time. So here goes.

Is a list a cheap kind of a "C" struct. Define the struct like

   const field1 = 0
   const field2 = 1
   const field3 = 2

and use these consts as list indexes. The struct is adjusted by changing the const's.

Using a dict gives the cleanest looking code, and I'd guess the worst performance.

Since I haven't looked at the vim9 VM, it may be that PUSHNR/LISTINDEX and LOADSCRIPT/LISTINDEX and MEMBER-'foo'/USEDICT are comparable (not talking tight loop) and it's purely psychological and I shouldn't use disassemble. But the constant value is typically available at compile time for LISTINDEX.

Something major I can't answer: are lists arrays or linked? That can change the balance towards dict.

-ernie

--
--
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/7c3c6ede-366a-56ab-3409-39ef1381b421%40raelity.com.

Raspunde prin e-mail lui