OK, makes sense, thanks.

> On 18 Feb 2022, at 11:29, Bram Moolenaar <b...@moolenaar.net> wrote:
> 
> 
>>> Wether a function is script-local or global (when not using a "s:" or
>>> "g:" prefix) depends on the script it's defined in The rule is "at the
>>> script level, the type of script defines what the scope of the items
>>> is". I think that's easy to understand. 
>> 
>> You know, I think the other rule is arguably easier to understand: "def 
>> functions are always script-local".
>> 
>> What are people's thoughts ?
>> 
>> In a sense the rule above could be used to advantage for "internal 
>> linkage" functions of a plugin. For example:
>> 
>> - I have a "public" interface of "function" functions - these are legacy 
>> vimscript for compatibility/interop
>> - internally in my "plugin" (let's say a single .vim file), I have some def 
>> functions for performance, convenience - they are script-local by default.
>> 
>> I admit the current behaviour is not difficult to explain or learn, but 
>> perhaps the "def functions are always internal unless "exported" or "g:" 
>> prefixed" is simpler logically?
> 
> Making :def functions always script-local would be OK.  But how about
> legacy functions?  If we connect the visibility to the type of function,
> you would expect a legacy function in a Vim9 script to be global.  But
> in a Vim9 script everything is script-local.  We even removed using "s:"
> for script level items.
> 
> So then the rule for :def functions would differ from legacy functions,
> which I find confusing.  If we make the script type define the
> visibility of items it's simpler and more logical.
> 
> -- 
> hundred-and-one symptoms of being an internet addict:
> 64. The remote to the T.V. is missing...and you don't even care.
> 
> /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
> ///                                                                      \\\
> \\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
> \\\            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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/FD75E1B4-44A4-47B6-BC3A-9BC806E09E33%40gmail.com.

Raspunde prin e-mail lui