Tuesday, November 3, 2020

Mixing Vim9 and legacy script (was: Happy birthday!)

Steve Litt wrote:

> > VIM 9 DEVELOPMENTS - MAKING VIM SCRIPT FASTER AND EASIER TO USE
> >
> > This is a big project. A lot of progress has been made, but it will
> > take time until we'll have "version 1.0". To make it possible to
> > compile a Vim script function, so that it can be executed 10-100 times
> > faster, it was required to make changes that are not backwards
> > compatible. Such as not having a dictionary and list for the function
> > arguments, since that causes too much overhead for every function
> > call.
> >
> > Once making changes that are not backwards compatible, it seemed like
> > a good idea to also make it easier to use Vim script. Or in other
> > words: "less weird". Using keywords and syntax that is similar to
> > popular programming languages helps a lot. At the same time we can
> > make the semantics more predictable and avoid mistakes. Type
> > checking is a great help with that, especially when writing a large
> > plugin.
>
> Thank you, thank you, THANK YOU! The old vimscript was so weird I had
> to do hours of trial and error just to do simple things, and there were
> a lot of things I couldn't do at all. Much/most of this was for
> VimOutliner, and I didn't want to require VimOutliner users to need to
> install Python extensions, so I used VimScript.
>
> > In case you don't like Vim 9 script, you can keep using the legacy
> > one, it won't go away and remain backwards compatible.
>
> Can I use some of one and some of the other, so I can slowly switch
> things to the new one?

Yes, each file can be legacy script or Vim 9 script and one can source
the other. You cannot switch halfway the file, that would be too
confusing.

You can use the new :def functions in legacy script. And you can use
legacy functions in Vim 9 script. However, the mix of syntax can be
confusing, thus I would recommend using :def functions in Vim 9 script
and legacy functions in legacy script. You can make exceptions where
you need to. E.g. keep using legacy script but move functionality that
needs to be fast into a :def function.

Keep in mind that Vim9 script is still under development, there are
still quite a few todo items.

--
Wizards had always known that the act of observation changed the thing that
was observed, and sometimes forgot that it also changed the observer too.
Terry Pratchett - Interesting times

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202011031044.0A3AiQ2L3729882%40masaka.moolenaar.net.

No comments: