Bob Hiestand wrote:

On 6/2/06, Charles E Campbell Jr <[EMAIL PROTECTED]> wrote:

Bob Hiestand wrote:

>  My question is whether there is a simpler way to pass an unknown
> number of arguments from the current function to a function which
> accepts a variable-length list of arguments.

...snip...


I don't think that does what I wanted, though I may have misunderstood
the implications.  That converts the arguments into a string
representation of a list, which then becomes the single argument to
the second function.

Looks like I made a mistake. Here's one that does illustrate passing a variable number of arguments along:

" ----------------------------------
fun! AFunc(...)
 let args = string(a:000)
 let len  = strlen(args)
 let args = strpart(args,1,len-2)
 echomsg "call BFunc(".args.") a:0=".a:0
 exe "call BFunc(".args.")"
endfun

" ----------------------------------
fun! BFunc(...)
 echomsg "BFunc sees: a:0=".a:0
 echomsg "a:000<".string(a:000).">"
endfun

" ----------------------------------
echomsg 'AFunc(1):'
call AFunc(1)

echomsg 'AFunc(1,"a"):'
call AFunc(1,"a")

echomsg 'AFunc(1,"a",b):'
let b="BBB"
call AFunc(1,"a",b)

The idea is to have a string hold just the arguments, not the list delimiters.
The exe squeezes the string together and then executes it.  Consequently,
the output is:

AFunc(1):
call BFunc(1) a:0=1
BFunc sees: a:0=1
a:000<[1]>
AFunc(1,"a"):
call BFunc(1, 'a') a:0=2
BFunc sees: a:0=2
a:000<[1, 'a']>
AFunc(1,"a",b):
call BFunc(1, 'a', 'BBB') a:0=3
BFunc sees: a:0=3
a:000<[1, 'a', 'BBB']>
P

So you can see that BFunc is being called with a variable number of
arguments depending on whatever AFunc received (look at the
BFunc sees: lines)


My intention was to create a passthrough function that could call any
other function after determining the function to which it would
dispatch control (the application here is a general source integration
script that would dispatch to the appropriate function specific to the
version control system controlling the current file).

As it turns out, I was a victim of narrow thinking because I was
trying to modify as little as possible of an existing plugin.  The
correct change was to simply make the dispatch function and the  end
functions accept a list as the parameter, in which case pass-through
becomes trivial.

Thank you for looking at this,

You're welcome!
Chip Campbell

Reply via email to