- From vim9 help I see *Functions and variables are script-local by default*
So s: is no mandatory no?, because if I put s: I see E1268: Cannot use s: in Vim9 script: s:yml_f = yml_fpath. - So I delete s: and obtain this 3.12.0b1 (tags/v3.12.0b1:5612078, May 22 2023, 16:20:31) [MSC v.1934 64 bit (AMD64)] <vim.dictionary object at 0x0000020790DC9380> regarding this code : vim9script def Py3_SimpleMinimalTest(yml_fpath: string): void var yml_f: string = yml_fpath exe 'py3 print(sys.version)' exe 'py3 print(vim.current.buffer.vars)' exe 'py3 print(vim.current.buffer.vars[''yml_f''])' enddef Py3_SimpleMinimalTest('foobar.yml') Then I got 3.12.0b1 (tags/v3.12.0b1:5612078, May 22 2023, 16:20:31) [MSC v.1934 64 bit (AMD64)] <vim.dictionary object at 0x0000020790DFFF00> Traceback (most recent call last): File "<string>", line 1, in <module> KeyError: 'yml_f' Le mercredi 31 mai 2023 à 16:13:20 UTC+2, Bram Moolenaar a écrit : > > > Thank you I knew, this is working > > > > vim9script > > > > def g:Py3_SimpleMinimalTest(yml_fpath: string): void > > w:yml_f = yml_fpath > > exe 'py3 print(sys.version)' > > exe 'py3 print(vim.current.window.vars[''yml_f''])' > > enddef > > > > and what about making this works > > > > def g:Py3_SimpleMinimalTest(yml_fpath: string): void > > *var yml_f:string =* yml_fpath > > exe 'py3 print(sys.version)' > > exe 'py3 print(vim.current.*????*.vars[''yml_f''])' > > enddef > > Do you mean you want to access variables local to a compiled function by > name? That is not possible. The "l:" namespace that exists in legacy > functions was intentionally left out in compiled functions, because it > adds quite a bit of overhead. You can use a script-local variable to > make this work. It does mean you go outside of the function scope, but > it's still inside the scope of the script file. That means it won't > interfere with what happens in other scripts. > > -- > From "know your smileys": > <>:-) Bishop > > /// Bram Moolenaar -- br...@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_use" 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_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/77f05256-1798-48fd-a794-265031be87e2n%40googlegroups.com.