On Fri, 8 Sep 2006 at 6:08am, A.J.Mechelynck wrote:

> Hari Krishna Dara wrote:
> [...]
> > I know that this is possible, but as I said previously, it is a force of
> > habit to compact as much as possible in some situations, though I
> > normally prefer using whitespace and parenthesis to improve clarity.
> >
> > Also, the reason I mentioned using spaces is not really as a workaround
> > but to show the subtle difference it makes to the parser. Once you use
> > parenthesis, there is nothing really ambiguous about it.
> >
> > I have a suspcion that using parenthesis also didn't solve the issue in
> > one of the cases (I remember it was calling script-local functions as
> > part of map() expression). I have to try to reproduce it though, I don't
> > remember it now.
> >
> As Tim said, a liitle bit of paranoia is healthy here: If you write
>       if condition_1 || condition_2 && condition_3
> the parser will interpret it in a well-defined way, determined by the
> syntax of the language, but when you come back 2 years hence, will it
> still be clear to you? Some languages mandate left-to-right order in
> this case, which results in the equivalent of
>       if (condition_1 || condition_2) && condition_3
> In others, "and" takes precedence over "or", which results in
>       if condition_1 || (condition_2 && condition_3)
> With parentheses, precedence rules are unimportant and an error in logic
> won't be overlooked even if you mistook a left-to-right language for an
> and-before-or language or vice-versa. similarly for all other possible
> ambiguities: remember, (x?a:1) is a valid expression if you have a
> variable named a. You may even have an argument named a:a so what about
> (x?a:a:a) if you have both a and a:a ? I repeat: don't trust priorities
> and use parentheses. And if you caught a bad habit, reeducate yourself.
> Best regards,
> Tony.

We are deviating from my original point. It is not that I don't know
what is more cleaner way of writing code that I asked this question. I
just want to write more compact code sometimes, and if that doesn't work
in this case, I will avoid, there is no convincing required. I don't
write this kind of code as a rule and it certainly is not my "regular"
habbit. May be my use of word "habbit" is wrong here, but you didn't
really have to give all the explanation. I am an experienced programmer
(and I don't write just Vim scripts), and if you look at my Vim scripts,
you will find that I write them very seriously (and passionately),
following my own coding standards, tediously splitting the long lines
for readability and doing all that you are suggesting here.

My intention was to report a problem I found, and sometimes minor
symptoms can lead to the discovery of major issues, so I don't generally
ignore any bugs. I also wanted to know (for educational purpose) if it
can even be parsed without ambiguity (ie., if the bug can even be fixed)
to which I think Bram answered NO, and that is the answer I was looking


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

Reply via email to