3 ms·
> D also does not allow the syntax `a < b < c`. C does, to the eternal damnation of anyone who tries it. Far be it for me to teach the Pope to pray, but would
by msla 4y ago
> D also does not allow the syntax `a < b < c`. C does, to the eternal damnation of anyone who tries it.
Far be it for me to teach the Pope to pray, but would it be reasonably reasonable to make that do the right thing? If your compiler can disallow it, it can detect it, so the grammar is obviously thinkable, and the semantics might be as well.
- lmz 4y agoI believe this is legal Python and does what you expect.
- afiori 4y agoIn the syntax `a < b < c` both the `<` are different operators than the `<` in `a < b`. It is more similar to the ternary operator `a ? b : c`. It could also just be a type error: `<` takes two integers and produces a boolean, so both `(a < b) < c` and `a < (b < c)` would be invalid.
- WalterBright 4y ago> would it be reasonably reasonable to make that do the right thing? I did think about that, and it's a good question. I did not out of concern for some C code translated to D then mysteriously misbehaving.