Reply to message «Re: vim function not first-class variable? how to create an 
alias for vim function ?», 
sent 12:41:23 05 July 2011, Tuesday
by Marc Weber:

> Note: F must be upper case, cause functions can only be assigned to
> upper case vars.
F can be inside dictionary, in this case it does not matter. It also avoids 
E705 
error: you can't do
    let Foobar=function('Foobar')
, but can
    let d={}
    let d.Foobar=function('Foobar')

> That implements a function reference by using a special key in a dict.
> This way you can also add args to the function ref:
> 
> let f = funcref#Function('FooBar',{'args': [ 1, 2] })
> 
> 
> call funcref#Call(f, [2,3])
> 
> will call FooBar(1,2,  2,3)
> 
> It also supports kind of eval functions definitions:
> 
> let f = funcref#Function("return ARGS[0]")
> 
> last but not least obj like functions:
> 
> let X = {}
> 
> fun X.A(a,b)
>   echo a:a
>   echo a:b
>  endf
> 
> call X.A(2,3)
> let C = X.A
> call call(C,[], X) " or the like
1. What is it for?
2. Why not f.call(args) instead of funcref#Call(f, [args])?

Original message:
> Excerpts from pansz's message of Tue Jul 05 10:24:05 +0200 2011:
> > I want to do some coding like this:
> let F = function('Foobar')
> 
> call call(F, [arg1, arg2], { optional self dict })
> 
> Note: F must be upper case, cause functions can only be assigned to
> upper case vars.
> 
> Also see vim-addon-mw-utils (on my github page).
> 
> That implements a function reference by using a special key in a dict.
> This way you can also add args to the function ref:
> 
> let f = funcref#Function('FooBar',{'args': [ 1, 2] })
> 
> 
> call funcref#Call(f, [2,3])
> 
> will call FooBar(1,2,  2,3)
> 
> It also supports kind of eval functions definitions:
> 
> let f = funcref#Function("return ARGS[0]")
> 
> last but not least obj like functions:
> 
> let X = {}
> 
> fun X.A(a,b)
>   echo a:a
>   echo a:b
>  endf
> 
> call X.A(2,3)
> let C = X.A
> call call(C,[], X) " or the like
> 
> Marc Weber

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

Reply via email to