Maxim Kim wrote:
> Shouldn't def functions be prohibited in legacy vimscript? > > https://vi.stackexchange.com/questions/36829/how-can-i-define-vim9-functions-and-vim9-lambdas-in-a-vim9-script > > Basically if you add > > def! Hello() > echo "hello world" > enddef > > to a regular legacy vim file (.vimrc, for example), function Hello is > globally defined and one can :call Hello() and get echoed "hello world". In case you have some code that needs to be executed fast, but the rest of the script has some stuff you don't want to convert to Vim9, then putting that code in a compiled function is very useful. Wether a function is script-local or global (when not using a "s:" or "g:" prefix) depends on the script it's defined in. An alternatie could be to make :def functions always script-local by default, then you would have to use "g:" to make them global. I don't think this helps and it can be confusing. 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. -- Keyboard not found. Think ENTER to continue. /// 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/20220217105912.88CEC1C0FEC%40moolenaar.net.