Translating complete functions to Vim9

18 views
Skip to first unread message

Lifepillar

unread,
Jun 19, 2021, 4:52:38 PM6/19/21
to vim...@googlegroups.com
Is there a way to turn a completion function (:h complete-functions)
into Vim9 script?

The issue is that such functions are called twice, and they are expected
to return values of different types in each call.

Thanks,
Life.

Bram Moolenaar

unread,
Jun 20, 2021, 9:32:51 AM6/20/21
to vim...@googlegroups.com, Lifepillar
You can use the return type "any".

I know in typescript it is possible to combine two types, e.g. you can
use "string | number". But not many other languages use this. I am not
convinced adding the combined type to Vim 9 script is a good choice.

For newly added builtin functions we will avoid mixing types, both for
the arguments and for the returned value. But several of the existing
functions do allow for different types, since they were designed for
runtime type checking.

--
hundred-and-one symptoms of being an internet addict:
28. You have comandeered your teenager's phone line for the net and even his
friends know not to call on his line anymore.

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