Ben Fritz wrote:

> > a restriction will be that script-local items
> > are defined once and not deleted.  That makes it possible to find them
> > by index, which is much faster than a dictionary lookup.
> 
> Does this mean "unlet" will no longer work for local variables if
> namespaces are used? How about exists(), does this add special cases?

Correct, to be able to find the declared variables by fixed position,
they cannot be removed.  Otherwise a function defined in the script that
uses the variable would break.  Or have to check at runtime that it
still exists, which slows it down.

In normal programming languages one can never remove a declared
variable, thus it can't be much of a disadvantage.  It's more getting in
line with normal programmers expectations.  That is for variables
declared in the script namespace.  Global variables can still be deleted
(and thus are slower to access), no plans to change that.

Perhaps there could be an optimization that when a variable is only used
at the script level and not anywhere in a function it could be dropped.
Don't even need to use :unlet, it would be automatic.  However, the gain
is small and making it work correctly is complicated.  In case the
variable actually uses a lot of memory, making it empty would be the
solution.

BTW: after implementing a few pieces of this I think the "namespace"
statement may be misleading.  The effect is much more than creating a
namespace.  Something like "vim9script" would be more appropriate.

And yes, this denies my original statement that the script level would
not be using Vim9 script syntax, thinking that it is not needed because
it is only executed once.  There are performance reasons to also use
Vim9 script syntax at the script level.  Maybe it's going a bit too far,
let's see how it works out.  At least I think we should not have a third
syntax for the script level, somewhere in between the legacy and the
Vim9 script one.  Better to limit to two syntax styles.  Thus for script
level it's all or nothing.

-- 
Why is "abbreviation" such a long word?

 /// 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202001131742.00DHgo4R029700%40masaka.moolenaar.net.

Raspunde prin e-mail lui