What about the following new binary operator?

        expr-a in expr-b

The result would be boolean (i.e. integer with value 0 or 1).

If expr-b is a List, then the result is 1 if there is a list item equal to expr-a, otherwise 0. This is equivalent (but IMHO more "readable") than the expression
        index(expr-b, expr-a) != -1

If expr-b is a Dictionary the result is 1 if there is a key equal to expr-a otherwise 0. IMHO more readable (and less cumbersome) than the equivalent
        get(expr-b, expr-a) != 0 || get(expr-b, expr-a, 1) != 1
or the rv variable returned by
        :try
        :       let value = expr-b[expr-a]
        :       let rv = 1
        :catch /^Vim(let):E71[36]:/     " empty key, or key not in dict
        :       let rv = 0
        :endtry

If expr-b is neither a List nor a Dictionary, trigger an error Ennn with some appropriate nnn.

There is no ambiguity after the :for command since the first operand "var" of
        :for var in list
must be a variable name, not an expression containing an operator, and the second operator "list" must be a List, not a Number.



This makes me think: what about:

        :for {var1}:{var2} in {dictionary}
        :       ...
        :endfo[r]

The loop would be executed once for every key:value pair, with {var1} set to the key and {var2} to the corresponding value.

Advantage: less cumbersome than the equivalent
        :for var1 in keys(dictionary)
        :       let var2 = dictionary[var1]
        :       ...
        :endfor


As you can see, neither one of these RFEs are very important since there already are workarounds; but they might improve readability, in a manner analogous to the already existing (new in Vim 7)
        :for i in range(var1, var2)
        :       ...
        :endfor
compared to the equivalent (and more backward-compatible but also more bulky)
        :let i = var1
        :let step = 2 * (var1 < var2) - 1       " +1 (yes), -1 (no)
        :while ((var2 - i) / step) >= 0
        :       ...
        :       let i = i + step
        :endwhile
        :unlet i step


Best regards,
Tony.
--
We're only in it for the volume.
                -- Black Sabbath

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


Raspunde prin e-mail lui