comparison runtime/doc/eval.txt @ 17667:95c23e180022

Update runtime files. commit https://github.com/vim/vim/commit/088e8e3443520dec91a384081e66445a104810bb Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 8 22:15:18 2019 +0200 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Aug 2019 22:30:08 +0200
parents da7890e3359b
children 06c3e15ad84d
comparison
equal deleted inserted replaced
17666:460af4da8fa6 17667:95c23e180022
1 *eval.txt* For Vim version 8.1. Last change: 2019 Aug 04 1 *eval.txt* For Vim version 8.1. Last change: 2019 Aug 08
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
4394 When {arglist} or {dict} is present this creates a partial. 4394 When {arglist} or {dict} is present this creates a partial.
4395 That means the argument list and/or the dictionary is stored in 4395 That means the argument list and/or the dictionary is stored in
4396 the Funcref and will be used when the Funcref is called. 4396 the Funcref and will be used when the Funcref is called.
4397 4397
4398 The arguments are passed to the function in front of other 4398 The arguments are passed to the function in front of other
4399 arguments. Example: > 4399 arguments, but after any argument from |method|. Example: >
4400 func Callback(arg1, arg2, name) 4400 func Callback(arg1, arg2, name)
4401 ... 4401 ...
4402 let Func = function('Callback', ['one', 'two']) 4402 let Partial = function('Callback', ['one', 'two'])
4403 ... 4403 ...
4404 call Func('name') 4404 call Partial('name')
4405 < Invokes the function as with: > 4405 < Invokes the function as with: >
4406 call Callback('one', 'two', 'name') 4406 call Callback('one', 'two', 'name')
4407
4408 < With a |method|: >
4409 func Callback(one, two, three)
4410 ...
4411 let Partial = function('Callback', ['two'])
4412 ...
4413 eval 'one'->Partial('three')
4414 < Invokes the function as with: >
4415 call Callback('one', 'two', 'three')
4407 4416
4408 < The function() call can be nested to add more arguments to the 4417 < The function() call can be nested to add more arguments to the
4409 Funcref. The extra arguments are appended to the list of 4418 Funcref. The extra arguments are appended to the list of
4410 arguments. Example: > 4419 arguments. Example: >
4411 func Callback(arg1, arg2, name) 4420 func Callback(arg1, arg2, name)
6194 call map(myDict, function('KeyValue')) 6203 call map(myDict, function('KeyValue'))
6195 < It is shorter when using a |lambda|: > 6204 < It is shorter when using a |lambda|: >
6196 call map(myDict, {key, val -> key . '-' . val}) 6205 call map(myDict, {key, val -> key . '-' . val})
6197 < If you do not use "val" you can leave it out: > 6206 < If you do not use "val" you can leave it out: >
6198 call map(myDict, {key -> 'item: ' . key}) 6207 call map(myDict, {key -> 'item: ' . key})
6208 < If you do not use "key" you can use a short name: >
6209 call map(myDict, {_, val -> 'item: ' . val})
6199 < 6210 <
6200 The operation is done in-place. If you want a |List| or 6211 The operation is done in-place. If you want a |List| or
6201 |Dictionary| to remain unmodified make a copy first: > 6212 |Dictionary| to remain unmodified make a copy first: >
6202 :let tlist = map(copy(mylist), ' v:val . "\t"') 6213 :let tlist = map(copy(mylist), ' v:val . "\t"')
6203 6214
10118 10129
10119 It is also possible to use `:eval`. It does not support a range, but does 10130 It is also possible to use `:eval`. It does not support a range, but does
10120 allow for method chaining, e.g.: > 10131 allow for method chaining, e.g.: >
10121 eval GetList()->Filter()->append('$') 10132 eval GetList()->Filter()->append('$')
10122 10133
10134 A function can also be called as part of evaluating an expression or when it
10135 is used as a method: >
10136 let x = GetList()
10137 let y = GetList()->Filter()
10138
10123 10139
10124 AUTOMATICALLY LOADING FUNCTIONS ~ 10140 AUTOMATICALLY LOADING FUNCTIONS ~
10125 *autoload-functions* 10141 *autoload-functions*
10126 When using many or large functions, it's possible to automatically define them 10142 When using many or large functions, it's possible to automatically define them
10127 only when they are used. There are two methods: with an autocommand and with 10143 only when they are used. There are two methods: with an autocommand and with