On Thu, Sep 17, 2015 at 8:05 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
> is there a way to make a function call another function w/o needing to
> quote the string?
>
> function! Test1(fn)
> call fn " also tried eval
> endfunction
>
> function! Test2(foo)
> echo foo
> endfunction
>
> :call Test1(Test2("bar"))
>
> should also technically work if i did:
> :call Test1(Test1(Test2("bar")))
>
> but neither does
>
":call Test1(Test2("bar"))" passes Test2("bar"), which is zero (a
function with no :return statement always returns zero) as the
argument of Test1.
To have Test1 compute something, then pass it back to a callback
function (which might be different between one call and the next), you
would have to pass a Funcref (q.v.) as one of its arguments. Then
Test1 would call the Funcref (the callback function) with the computed
value as argument.
If you only want to use in Test1() some value computed by Test2(),
then the latter would have to pass it in a :return (q.v.) statement,
not via :echo. No Funcref needed in this case, since there is no
callback (i.e., no function to call out-of-band to signal completion).
Best regards,
Tony.
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thursday, September 17, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment