|
From: | Davis Herring |
Subject: | Re: [Emacs-diffs] master 6354e3c: Handle indentation of nested ternary operators in JS |
Date: | Thu, 13 Apr 2017 15:36:05 -0600 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
+ isSet + ? (isEmpty ? 2 : 3) + : 4Not sure about JS, but at least in C, those parentheses are not needed
JavaScript and C have the same ?: parsing. Moreover, I think even PHP would get that one right without parentheses, because grouping the first ? and : and the second ? and : would be self-intersecting.
(What PHP gets wrong is !isSet ? 4 : isEmpty ? 2 : 3 which it, unlike all sane languages, parses as (!isSet ? 4 : isEmpty) ? 2 : 3 aka !isSet || isEmpty ? 2 : 3 which is rarely what was intended.) Davis --This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.
[Prev in Thread] | Current Thread | [Next in Thread] |