Yasuhiro Matsumoto wrote:

> I hope vim can treat list argument for or()/and()/xor().
> Currently, spec is two arguments. or({expr}, {expr}).
> But many of case I want is:
> 
> -------
> let FLAG1 = 0x0001
> let FLAG2 = 0x0002
> let FLAG3 = 0x0004
> if (s:check_flag([FLAG1, FLAG2, FLAG3])
>   " do something
> endif
> -------
> 
> If you write above in current vim,
> 
> -------
> let FLAG1 = 0x0001
> let FLAG2 = 0x0002
> let FLAG3 = 0x0004
> echo or(or([FLAG1, FLAG2), FLAG3])
> -------
> 
> It is lengthy.  I thought about variadic function/arguments. But vim dont 
> support true variadic function.
> printf() has limit of arguments 19. So I wrote a patch to accept list the 
> argument.
> 
> https://gist.github.com/1751166
> https://raw.github.com/gist/1751166/gistfile1.diff
> 
> This is patch for suggestion. Is this better to write separated in doc like 
> below?
> 
> and( {expr}, {expr}) Number  bitwise AND
> and( {list} ) Number  bitwise AND

For consistency we need to mention the second argument as optional.  I
think it's fine, the user will want to read the detailed explanation
anyway.

For the code: It duplicates very similar code in three places.  Can you
make this a function that accepts an argument that specifies the operation?

It would also be better to compute the result in a local variable and
assign it to rettv->vval.v_number at the end.

-- 
hundred-and-one symptoms of being an internet addict:
36. You miss more than five meals a week downloading the latest games from
    Apogee.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui