On 5/16/06, Eric Arnold <[EMAIL PROTECTED]> wrote:
Have you thought about making it a dict function, and passing in and
out via the self dict?


function Mylen() dict
        let self['newkey'] = 'newvalue'
        return len(self.data)
endfunction
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
echo mydict.len()
echo mydict.newkey


You can then pass in the type meta data in one key, and the actual
data(num,string,list,dict) in another.


On 5/16/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> On 5/16/06, Bob Hiestand <[EMAIL PROTECTED]> wrote:
> >  I'm re-writing my cvscommand.vim plugin to handle both CVS and
> > Subversion version control systems.  I'm currently implementing some
> > of the functionality through function references that define common
> > operations for each source control system in a dictionary specfic to
> > that system.  I have a situation where I have a generic dispatch
> > function that identifies which dictionary to dereference to obtain the
> > function reference.
> >
> >  The problem is that the function eventually called behind the
> > function reference may have any number of arguments.  Therefore, the
> > dispatch function takes any number of arguments to pass through.  This
> > leads to the actual call, which looks like this (all on one line):
> >
> > function! s:ExecuteVCSCommand(command, ...)
> >  " find the proper functionMap dictionary, and then:
> >  execute "return functionMap[a:command](" . join(map(copy(a:000),
> > "'\"' . v:val . '\"'"), ",") . ")"
> >
> >  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.
>
> The only thing I can think of is rewriting target functions
> into accepting 1 argument which is a list. I don't find
> vim vararg mechanism easy to use in general.
>
> Yakov
>

Reply via email to