Lines Matching refs:function
45 compatible. For example, making function arguments available in the
46 "a:" dictionary adds quite a lot of overhead. In a Vim9 function this
51 - a function defined with the `:def` command
56 When using `:function` in a Vim9 script file the legacy syntax is used, with
67 function.
71 useful in a Vim9 script or a :def function.
148 A function defined with `:def` is compiled. Execution is many times faster,
151 Many errors are already found when compiling, before the function is executed.
155 - the first time the function is called
157 function was defined
158 - `:disassemble` is used for the function.
159 - a function that is compiled calls the function or uses it as a function
170 `:def` has no options like `:function` does: "range", "abort", "dict" or
171 "closure". A `:def` function always aborts on an error (unless `:silent!` was
173 cannot be a "dict" function, and can always be a closure.
174 *vim9-no-dict-function*
175 Later classes will be added, which replaces the "dict function" mechanism.
183 You can call a legacy dict function though: >
205 When a function argument is optional (it has a default value) passing `v:none`
226 When using `:function` or `:def` to specify a new function at the script level
227 in a Vim9 script, the function is local to the script, as if "s:" was
228 prefixed. Using the "s:" prefix is optional. To define a global function or
234 def scriptname#function() # autoload
236 When using `:function` or `:def` to specify a nested function inside a `:def`
237 function, this nested function is local to the code block it is defined in.
238 In a `:def` function it is not possible to define a script-local function. It
239 is possible to define a global function by using the "g:" prefix.
241 When referring to a function and no "s:" or "g:" prefix is used, Vim will
242 search for the function:
243 - in the function scope, in block scopes
246 However, it is recommended to always use "g:" to refer to a global function
249 Since a script-local function reference can be used without "s:" the name must
255 In all cases the function must be defined before used. That is when it is
267 When compiling a function and a function call is encountered for a function
269 You can use an autoload function if needed, or call a legacy function and have
301 Variables can be local to a script, function or code block: >
353 Although using a :def function probably works better.
369 Variables, functions and function arguments cannot shadow previously defined
388 *vim9-function-defined-later*
390 exist when compiled. By adding the "g:" prefix the function can be defined
402 PluginFunc() # Error - function not found
406 You can use exists_compiled() to avoid the error, but then the function would
418 similar to how a function argument can be ignored: >
471 identifier or can't be an Ex command. For a function either "(" or "->" must
482 In the rare case there is ambiguity between a function name and an Ex command,
484 is both the `:substitute` command and the `substitute()` function. When the
485 line starts with `substitute(` this will use the function. Prepend a colon to
498 since the function has to be looked up by name. And a typo in the function
499 name will only be found when the function is called.
502 Omitting function() ~
504 A user defined function can be used as a function reference in an expression
505 without `function()`. The argument types and return type will then be checked.
506 The function must already have been defined. >
510 When using `function()` the resulting type is "func", a function with any
511 number of arguments and any return type (including void). The function can be
545 arguments, use "..._", which makes the function accept
550 < *inline-function*
601 With a function call: >
645 If the heredoc is inside a function 'cpoptions' must be set before :def and
676 It is also possible to split a function header over multiple lines, in between
698 current function.
743 - Between a function name and the "(": >
869 func when there is a function name
961 Functions defined with `:def` compile the whole function. Legacy functions
994 The `exists_compiled()` function can also be used for this.
996 Another side effect of compiling a function is that the presence of a user
1047 Define a new function by the name {name}. The body of
1048 the function follows in the next lines, until the
1052 function is not expected to return anything.
1064 The function will be compiled into instructions when
1070 `:function` up to about 50 levels deep.
1072 [!] is used as with `:function`. Note that
1078 :enddef End of a function defined with `:def`. It should be on
1084 If the script the function is defined in is Vim9 script, then script-local
1086 before the function is compiled. If the script the function is defined in is
1118 function scope. Instead, use a lambda: >
1149 for each closure call a function to define it: >
1193 A partial and function can be declared in more or less specific ways:
1194 func any kind of function reference, no type
1201 func() function with no argument, does not return a
1204 func(): {type} function with no argument and return type
1206 func({type}) function with argument type, does not return
1208 func({type}): {type} function with argument type and return type
1209 func(?{type}) function with type of optional argument, does
1211 func(...{type}) function with type of variable number of
1214 function with:
1220 If the return type is "void" the function does not return a value.
1251 Variables declared in Vim9 script or in a `:def` function have a type, either
1276 it to a string, use the |string()| function. Or use |str2nr()| to convert a
1294 The common type of function references, if they do not all have the same
1307 variable was declared in a legacy function.
1367 be available as `g:myvar` from any other script and function.
1449 `:import` can not be used in a function. Imported items are intended to exist
1491 must be exactly the same as the prefix for the function name, that is how
1502 When compiling a `:def` function and a function in an autoload script is
1503 encountered, the script is not loaded until the `:def` function is called.
1530 - Generics for function: `def <Tkey> GetLast(key: Tkey)`
1569 shown that keeping the existing semantics of function calls make this close to
1570 impossible, because of the overhead involved with calling a function, setting
1571 up the local function scope and executing lines. There are many details that
1576 Therefore the `:def` method to define a new-style function had to be added,
1577 which allows for a function with different semantics. Most things still work
1578 as before, but some parts do not. A new way to define a function was
1581 Using "def" to define a function comes from Python. Other languages use
1582 "function" which clashes with legacy Vim script.
1614 - Drop `:call` for calling a function and `:eval` for manipulating data.
1777 the exported function(s) and class(es).
1814 The drawback is that if a function never gets called, the overhead of