Andy Massimino wrote:

> On Thu, Aug 8, 2019, 10:29 AM 'Andy Wokula' via vim_dev <
> vim_dev@googlegroups.com> wrote:
> 
> > :h expr-lambda
> >
> > I think this is a design mistake:
> >      :echo map([1, 2, 3], {idx, val -> val + 1})
> >
> > It should be
> >      :echo map([1, 2, 3], {val, idx -> val + 1})
> >
> > 95% of map() expressions do not need v:key (er, idx).
> >
> > It annoys me whenever I use it.
> >
> > Especially nice: dummy examples that are off-by-one without error:
> >      :echo map([1,2,3], {x -> x+10})
> >      => [10, 11, 12]
> > Great stuff!
> >
> > Please change this, backwards incompatibly.
> > Also for filter().
>
> I also think this is a problem.. but can't think of any good way to solve
> it.  My best guess is to add a new scriptversion which would require the
> lambda to take exactly two arguments.  But this won't catch simply swapping
> idx and val by accident.

I think not checking for the correct number of arguments is the bigger
problem, it leads to mistakes.  But changing this will cause existing
script to fail, so let's not do that.

I don't think it's much of an issue, but if we want to do something,
adding a mapval() function, which only uses the value, would be an
option.

-- 
Not too long ago, compress was something you did to garbage...

 /// Bram Moolenaar -- b...@moolenaar.net -- 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201909241619.x8OGJSne024461%40masaka.moolenaar.net.

Raspunde prin e-mail lui