Hari Krishna Dara wrote:
> I have hit this thrice already, while using the ?: ternary operator, in
> some conditions, you are forced to put whitespace to separate the
> operator otherwise Vim gets confused. Here is something that fails:
>
> let direction = (a:0?a:1:1)
>
> I had this issue before calling script-local functions from the
> true or false condition. The workaround as I said for the above is:
>
> let direction = (a:0 ? a:1 :1)
>
> The problem is, sometimes I have a force of habit to skip the whitespace
> in some places when I want the code to be really compact/tight
> (especially when with map(), filter() or \=), and I will not notice the
> problem until sometime later when the code gets executed. If the code
> happened to execute with a :silent, you may have to do quite a bit of
> debugging to find this kind of errors. Is it possible for Vim to parse
> this unambiguously? The usage could be even worse, something like:
>
> let direction = (a:0>1?a:2:a:1)
The ":" is overloaded, it's used both after a variable name and for ? :.
You need to put a space before it when you want to use it for ? :.
There is no other solution for this. Adding spaces is good for
readability anyway. This is much easier to understand:
let direction = a:0 ? a:1 : 1
Than this:
let direction = a:0?a:1:1
--
ARTHUR: Then who is your lord?
WOMAN: We don't have a lord.
ARTHUR: What?
DENNIS: I told you. We're an anarcho-syndicalist commune. We take it in
turns to act as a sort of executive officer for the week.
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///