On 31-May-2013 15:14 +0200, mattn wrote:

> Hi all.
> 
> filter() or map() is given {string} expression to compare the items. But 
> sort() is given function name or funcref for that.
> I hope to give expression to {func}.
> 
> I guess this is useful to call sort().
> 
> :echo sort([{"foo":3},{"foo":2},{"foo":4}], "v:lhs.foo - v:rhs.foo")
> [{'foo': 2}, {'foo': 3}, {'foo': 4}]
> 
> Below is a patch. Please check and include.
> This patch still allow to give string for function name.
> 
> https://gist.github.com/mattn/5684747

Is this really such a frequent use case? I'm reluctant to introduce two
more special variables (v:lhs, v:rhs; especially with these very
ambiguous (think mappings) names! Why not v:i1 / v:i2?) just for this.

Rather, I'd love to see an easier way to define anonymous Funcrefs
inline, as in this imaginary syntax:

    echo sort([{"foo":3},{"foo":2},{"foo":4}], function(i1, i2)
        return a:i1.foo - a:i2.foo
    endfunction)

That would be even more useful for the mentioned map() and filter(),
where the double escaping of the expression is really ugly. To
summarize, I'd rather see this addressed by allowing more uses for
Funcrefs rather than introducing more occasions for expressions.

-- regards, ingo

-- 
-- 
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/groups/opt_out.


Raspunde prin e-mail lui