Yegappan wrote:
> On Mon, Dec 13, 2021 at 7:32 AM Yegappan Lakshmanan <[email protected]> > wrote: > > > > Hi, > > > > Inside a Vim9 def function, I am not able to create a legacy > > script-local function > > using the "s:" prefix. Example: > > > > ---------------------------------------------------------------------------------------- > > vim9script > > > > def T() > > func s:F1() > > endfunc > > var Fn: func = s:F1 > > enddef > > defcompile > > > > func s:F2() > > endfunc > > > > var Fn: func = s:F2 > > ---------------------------------------------------------------------------------------- > > > > When I source the above script, I get the "E1075: Namespace not > > supported: s:F1()" > > error message. > > > > I am able to define a script-local function using the "s:' prefix at the > > script > > level though. > > > > The same issue applies to Vim9 def function also: > > ---------------------------------------------------------------------------------------- > vim9script > > def T() > def s:F1() > enddef > var Fn: func = s:F1 > enddef > defcompile > > def s:F2() > enddef > var Fn: func = s:F2 > ---------------------------------------------------------------------------------------- > > If I source the above script, I get the "E1075: Namespace not > supported: s:F1()" error message. But at the script level, there is no > error. The basic idea is that script-local functions are defined at the script level. And not created or deleted dynamically. The main reason is that in a compiled :def function these script functions can be called by index, instead of having to look them up by name (and handle failure). That is more efficient and allows for type checking of arguments and return value. Currently this function lookup by index only happens for :def functions, but it could also be done for legacy functions. Applying the same rule for both type of functions is more consistent anyway. -- Time is an illusion. Lunchtime doubly so. -- Ford Prefect, in Douglas Adams' "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- [email protected] -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20211213203940.8C9361C0D69%40moolenaar.net.
