Vim 9 function arguments (was: Happy birthday!)

13 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 4, 2020, 7:39:16 AM11/4/20
to vim...@googlegroups.com, BPJ, vim-dev

> > 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 -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages