diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-01 15:40:54 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-01 15:40:54 +0200 |
commit | 437bafe4c8a83ed71ee006eda7f54b65a90f0d4c (patch) | |
tree | dac9426b1bafe44f050bbb13c027de31117c089d /runtime | |
parent | 580164481924ed8611eb79f0247a0eb1ca0b3b9a (diff) | |
download | vim-git-437bafe4c8a83ed71ee006eda7f54b65a90f0d4c.tar.gz |
patch 7.4.2137v7.4.2137
Problem: Using function() with a name will find another function when it is
redefined.
Solution: Add funcref(). Refer to lambda using a partial. Fix several
reference counting issues.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/eval.txt | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 8dfbb3a28..7e0b73c61 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Jul 29 +*eval.txt* For Vim version 7.4. Last change: 2016 Jul 31 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1240,7 +1240,9 @@ function returns: > :let Bar = Foo(4) :echo Bar(6) < 5 -See also |:func-closure|. + +See also |:func-closure|. Lambda and closure support can be checked with: > + if has('lambda') Examples for using a lambda expression with |sort()|, |map()| and |filter()|: > :echo map([1, 2, 3], {idx, val -> val + 1}) @@ -2071,8 +2073,10 @@ foldlevel({lnum}) Number fold level at {lnum} foldtext() String line displayed for closed fold foldtextresult({lnum}) String text for closed fold at {lnum} foreground() Number bring the Vim window to the foreground -function({name} [, {arglist}] [, {dict}]) +funcref({name} [, {arglist}] [, {dict}]) Funcref reference to function {name} +function({name} [, {arglist}] [, {dict}]) + Funcref named reference to function {name} garbagecollect([{atexit}]) none free memory, breaking cyclic references get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def} get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def} @@ -3850,6 +3854,15 @@ foreground() Move the Vim window to the foreground. Useful when sent from {only in the Win32, Athena, Motif and GTK GUI versions and the Win32 console version} + *funcref()* +funcref({name} [, {arglist}] [, {dict}]) + Just like |function()|, but the returned Funcref will lookup + the function by reference, not by name. This matters when the + function {name} is redefined later. + + Unlike |function()|, {name} must be an existing user function. + Also for autoloaded functions. {name} cannot be a builtin + function. *function()* *E700* *E922* *E923* function({name} [, {arglist}] [, {dict}]) @@ -3857,12 +3870,16 @@ function({name} [, {arglist}] [, {dict}]) {name} can be the name of a user defined function or an internal function. - {name} can also be a Funcref, also a partial. When it is a + {name} can also be a Funcref or a partial. When it is a partial the dict stored in it will be used and the {dict} argument is not allowed. E.g.: > let FuncWithArg = function(dict.Func, [arg]) let Broken = function(dict.Func, [arg], dict) < + When using the Funcref the function will be found by {name}, + also when it was redefined later. Use |funcref()| to keep the + same function. + When {arglist} or {dict} is present this creates a partial. That means the argument list and/or the dictionary is stored in the Funcref and will be used when the Funcref is called. @@ -6191,6 +6208,7 @@ screenrow() *screenrow()* The result is a Number, which is the current screen row of the cursor. The top line has number one. This function is mainly used for testing. + Alternatively you can use |winline()|. Note: Same restrictions as with |screencol()|. @@ -8039,6 +8057,7 @@ insert_expand Compiled with support for CTRL-X expansion commands in Insert mode. jumplist Compiled with |jumplist| support. keymap Compiled with 'keymap' support. +lambda Compiled with |lambda| support. langmap Compiled with 'langmap' support. libcall Compiled with |libcall()| support. linebreak Compiled with 'linebreak', 'breakat', 'showbreak' and @@ -8294,7 +8313,7 @@ See |:verbose-cmd| for more information. :endf[unction] The end of a function definition. Must be on a line by its own, without other commands. - *:delf* *:delfunction* *E130* *E131* + *:delf* *:delfunction* *E130* *E131* *E933* :delf[unction] {name} Delete function {name}. {name} can also be a |Dictionary| entry that is a |Funcref|: > |