2016-07-08 13:36 GMT+03:00 Bram Moolenaar <[email protected]>:
>
> 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

>
> We might want to make the ":silent" part optional then.
>
> --
> hundred-and-one symptoms of being an internet addict:
> 233. You start dreaming about web pages...in html.
>
>  /// 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

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

Raspunde prin e-mail lui