On Jul 5, 10:24 am, pansz <[email protected]> wrote: > I want to do some coding like this: > > :func! Foobar(...) > :endf > :let s:myfuncname = Foobar > :call s:myfuncname(1,2,3,4,5) > > if function name is first-class variable this should work, however it > does not work. > > then is there any method to define an alias for a function?
Function variables are not first-class variables in Vim. Internally a function reference is a variable of type VAR_FUNC and it's contents is the name of the function, a string. In the example below, calling F will actually call two different functions 's:Local'. The third call will fail because at that point F references an inexistent function name. If F were a first-class variable, the code of the first 's:Local' function would be executed in all three cases. Marko " MakeSID is defined in VxLib plugin " the statement creates a variable s:SNR ( = '<SNR>' . script_number . '_' ) exec vxlib#plugin#MakeSID() function! s:Local(a) echo a:a endfunc let F = function(s:SNR . "Local") call call(F, ["Works"]) function! s:Local(a) echo a:a . " again" endfunc call call(F, ["Works"]) delfunc s:Local call call(F, ["Doesn't work"]) -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
