Nikolay Pavlov wrote:

> >> I am also wondering why evalcmd()? When discussing the name in Neovim
> >> bug tracker I was against `evalcmd()` because for `eval('expr')`
> >> expression result is expected to be the only effect (though it is not
> >> necessary, most expressions used with `eval()` do not have
> >> side-effects). Commands on the other side do not have any results of
> >> evaluation at all, they are run for their side-effects and `capture()`
> >> just records one of their side-effects, so `eval…` is not a good name.
> >> Note that this function is not going to be used only for capturing
> >> output, in some cases it will be just a replacement for `:execute`
> >> which works in expression context.
> >
> > Yeah, I'm also not happy with evalcmd().  It seemed right at first, but
> > comparing to eval() it's quite different.
> >
> > I also don't like capture(), since it's actually executing the commands.
> >
> > It's actually more like system(), which already was a weird name from
> > old days.
> >
> > Perhaps we should call it execute() ?
> > It's executing commands and returning the output seems like an obvious
> > thing for such a function to return.
> 
> Main argument against `execute()` was that “executing commands” is
> obvious and common, but “returning the output” is not. `exec` from
> Python or Vim do not do this: in Python it returns None (unless it is
> Python 2 where it is a keyword with special syntax and not a function,
> so one cannot say it returns anything at all), in Vim it is a command
> itself, `exec` in C/shell is entirely different, but again not
> returning an output: here it either returns an error or replaces the
> current process.
> 
> I would really suggest to read the [issue][1] in Neovim bug tracker,
> there were many suggestions. And now, besides arguments that can be
> found there, there is additionally “Neovim already has such function
> and it is named `capture()`”.
> 
> [1]: https://github.com/neovim/neovim/pull/4697

I browsed through the thread, and exec() or execute() was among the
favorites.  I think the arguments for capture() are rather weak.  The
arguments for execute() are stronger, such as that it's similar to the
:execute command.  Again, putthing the emphasis on execution instead of
getting the output is fine.  For me capture() raises the question:
capture what?  I don't have hints from other languages, I don't think
any major language has a capture() function.

If we make setting the silent flag optional then execute() makes total
sense.

-- 
"After a few years of marriage a man can look right at a woman
without seeing her and a woman can see right through a man
without looking at him."
 - Helen Rowland

 /// 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.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui