Reputation: 504
Rescently I am in favor of a Vim plugin called Vundle. a dict named as g:bundle
has a item:
{'path': function('1')}
If I call the item.path(), Vundle can invoke "s:bundle.path()" in vundle/config.vim :
func! s:bundle.path()
return s:expand_path(g:bundle_dir.'/'.self.name)
endf
So, could you tell me the usage about parameter "1" of anonymous function in Vimscript?
Updated:
Thanks for Mr. Karkat.
I use :function {1}
command, whose result is:
function 1() dict
return s:expand_path(g:bundle_dir.'/'.self.name)
endfunction
the function block is same as s:bundle.path()
, it proves that number in braces means Funcref
:
The function will then get a nusmber and the value of dict.len is a Funcref that references this function. The function can only be used through a Funcref. It will automatically be deleted when there is no Funcref remaining that refers to it.
Referance:
https://github.com/gmarik/Vundle.vim/blob/master/autoload/vundle/config.vim#L106 http://vimdoc.sourceforge.net/htmldoc/eval.html#Dictionary-function
Upvotes: 1
Views: 736
Reputation: 172698
What you see is an anonymous Dictionary function. What this means is that for the Dictionary {'path': function('1')}
(let's call it foo
, and we know that it's an element of g:bundles
), there has been defined this:
let foo = {}
function foo.path() dict
return "foo"
endfunction
You can find out more about the function definition via
:function {1}
Upvotes: 1