[resend - message was rejected somewhere]

> * Bram Moolenaar <[email protected]> [230314 13:24]:
> > 
> > Ernie Rael wrote:
> > 
> > > I sometimes want "collection->foreach((_, v) => ...v...)", a simple
> > > one liner, no return or return ignored. I know it's not a performance
> > > winner, or I'd want it more.
> > > 
> > > After a quick look at the code, it looks like simply introducing
> > > another filtermap_T, FILTERMAP_FOREACH, and there's not much coding
> > > needed (I only looked at list). Probably more work doing tests/doc.
> > > 
> > > Any objections or other considerations?
> > 
> > So, this would iterate over the items in a List or Dictionary and invoke
> > a function for each one.  I assume the List or Dictionary is not
> > modified, otherwise you would use map().  Thus it's a short version of a
> > for loop.  This seems useful.
> > 
> > I would suggest first writing the help and think of any error conditions
> > that need to be handled.  Perhaps the collection should be locked
> > (frozen) to avoid trouble?
> 
> Would this have any functionality that is not provided by using mapnew
> and ignoring or throwing away the result?

It is not adding functionality, it is restricting functionality.
Using mapnew() suggests that the list/dict is going to be modified, only
by taking care it would be avoided.  And it adds overhead, a new
list/dict is created and items added to it.

-- 
FATHER: One day, lad, all this will be yours ...
PRINCE: What - the curtains?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230322164149.6867F1C07BD%40moolenaar.net.

Raspunde prin e-mail lui