Em 23-08-2013 01:01, Nikolay Pavlov escreveu:
>
> On Aug 23, 2013 1:24 AM, "Jakson Alves de Aquino" <[email protected]
> <mailto:[email protected]>> wrote:
>>
>>
>> Hi,
>>
>> The documentation of Funcref includes the following statement:
>>
>> A Funcref variable must start with a capital, "s:", "w:",
>> "t:" or "b:".
>>
>> It seems that sentence is incomplete. I think the intention was to
>> write:
>>
>> A Funcref variable must start with a capital letter and both
>> the function being referred to and the Funcref variable must
>> have the same scope, being prefixed by "s:", "w:", "t:" or
>> "b:".
>
> I do not understand. Vim currently has nothing else but global
> functions. There are no scoped ones, s:Fname is simply a shortcut for
> <SNR>N_Fname, where N is current script number. Anonymous functions are
> global ones with just N as their name, N is number of anonymous
> functions defined in this session (i.e. it is just an incremented counter).
>
> Thus I have not seen the "must have the same scope" behavior you describe.
I'm glad that my understanding of the sentence was wrong because I
want both the function and the Funcref to be global.
> Also note that using b:Fname (or g:Fname) as function name is
> undocumented. And it is as well NOT a name of buffer-local function.
>
>> But there is other problem in the documentation: although not
>> mentioned, "g:" also works even if it isn't explicitly prefixed in
>> the script, as in the example below where script_b.vim sources
>> script_a.vim. If we do :so % while editing script_b.vim,
>> FunctionA is executed:
>>
>> " script_a.vim:
>> function FunctionA()
>> echo "Hello World!"
>> endfunction
>>
>> " script_b.vim
>> source script_a.vim
>> let CallFunctionA = function("FunctionA")
>> call CallFunctionA()
>>
>> Note: I'm using global Funcref to global functions in the
>> Vim-R-plugin. So I hope that the problem is in the documentation
>> and not in the actual Vim behavior.
>
> I would say that putting funcrefs directly into global or function-local
> variable is the worst idea: your code will break if someone defines
> CallFunctionA function. Use dictionaries:
>
> let d={}
> let d.CallFunctionA = function("FunctionA")
Thanks for the suggestion, but actually I incentive people to
create extensions to the Vim-R-plugin which will source other
scripts if the vimrplugin_source variable is defined.
--
Jakson Alves de Aquino
Federal University of CearĂ¡
Social Sciences Department
www.lepem.ufc.br/aquino.php
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.