* Bram Moolenaar <b...@moolenaar.net> [220103 07:07]: > > > On 2021-12-30, Bram Moolenaar <b...@moolenaar.net> wrote: > > > If you have remarks on something in Vim9 script that you think should be > > > different, speak up now! Soon we'll only make backwards compatible > > > changes to avoid breaking existing plugins. > > > > There was a thread about this on HN a few days ago, and one of the > > comments suggested to reverse the import syntax so that the imported > > script is named first and the imported entities next. A rationale for > > this is that it would help automatic completion. > > Is there another language that works like this? The current syntax > resembles Javascript, which hopefully some users are familiar with.
I have to agree that putting the file being imported first is much better. In Go, by default every imported identifier must be prefixed by the package name, much like the current Vim9 "as" clause. Requiring an "as" clause (or defaulting to some form of the script name for the value of the "as" clause), and requiring that all imported identifiers be prefixed by this identifier make the code _much_ clearer and easier to follow. I very much dislike the JavaScript style where importing, by default, places the imported names in the current namespace rather than in a separate namespace (identified by the "as" clause in Vim9). Given that even when you are only importing one identifier from a script, the whole script must be read and executed, I think the Go way is better. Don't bother with the import MyClass from "myclass.vim" import {someValue, MyClass} from "thatscript.vim" syntax, and only provide import "myclass.vim" import "myclass.vim" as Other and require use of the namespace prefix: Other.MyClass The first case, without the "as" would default to the file name, with leading directories and trailing ".vim" removed, and with the first letter capitalized. Non-identifier characters and leading digits would be removed as well. In the case without "as" above, you would reference the imported MyClass identifier as Myclass.MyClass With this, every use of an imported identifier is clear and explicit. ...Marvin -- -- 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/YdL35xfbRHlaYZU5%40basil.wdw.