4 ms·
TL;DR; ? would be better, but it would completely break our parser. (The feature that conflicts, array literals, are using the obviously desirable syntax as we
by moomin 7y ago
TL;DR; ? would be better, but it would completely break our parser.
(The feature that conflicts, array literals, are using the obviously desirable syntax as well. This is just good intentions and path dependence in action.)
- dmurray 7y agoIt's not like it's an implementation detail of their parser, it would make the language more difficult to write correctly and still be parsed by any parser, including a human reading the code.
- moomin 7y ago100% agree, it just an unfortunate interaction between 1) ?: syntax 2) [] for dereferencing 3) [] for literals 4) ? for null chaining Each of the decisions is correct in isolation, but together they’re a nightmare. Which decision you made first determines what you end up with in the other areas.
- munificent 7y agoExactly right. If I had a time machine, (1) is what I'd fix. The conditional operator syntax has always been pretty hokey and if you just make `if` an expression (along with most other statement forms), you have no need for it.