Reply to message «Aw: Re: Aw: Re: vim function not first-class variable? how to 
create an alias for vim function ?», 
sent 20:01:56 07 July 2011, Thursday
by lith:

> Such "anonymous" dictionary functions a.k.a. numbered functions can be
> called by there name too. You can thus do the following:
I should have tested this: I though that as function() forbids to create a 
reference out of a number, call() will also forbid to call a function.

Original message:
> Am Mittwoch, 6. Juli 2011 19:34:05 UTC+2 schrieb ZyX:
> > There are anonymous functions (:h numbered-function):
> >     let s:F={}
> >     function s:F.func()
> >     
> >         echo "Here"
> >     
> >     endfunction
> > 
> > . It is not possible to call anonymous function without a reference to it
> > and
> > you can't create the reference using function() call, so the above code
> > effectively restricts write/execute access to the script (unless you pass
> > s:F.func, s:F or s: somewhere).
> 
> Such "anonymous" dictionary functions a.k.a. numbered functions can be
> called by there name too. You can thus do the following:
> 
> let d = {}
> function! d.Foo() dict
>     return 10
> endf
> 
> echo d.Foo()
> " => 10
> 
> echo d["Foo"]
> " => 93
> 
> echo call(93, [], d)
> " => 10
> 
> These anonymous functions thus aren't really anonymous if you know the
> number.
> 
> Regards,
> Tom

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to