Wednesday, November 4, 2020

Vim 9 function arguments (was: Happy birthday!)

> > 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.
>
> Does this mean
>
> - That there are no varargs?
> - That varargs are made available in some other way?

You can have arguments with default values, which are optional, and the
last argument can be a list, as explained in the help:

Variable arguments are defined as the last argument, with a name
and have a list type, similar to TypeScript. For example, a
list of numbers: >
def MyFunc(...itemlist: list<number>)
for item in itemlist


> - That you can't pass lists and dictionaries as arguments? (Not likely!)

Of course you can. But you can't access the arguments with the "a:"
dictionary or the a:000 list. Not only was this inefficient, it was
also rather weird. I don't think this will be missed.


--
hundred-and-one symptoms of being an internet addict:
194. Your business cards contain your e-mail and home page address.

/// 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/202011041238.0A4CcuwI4023620%40masaka.moolenaar.net.

No comments: