I apologise if I'm making more suggestions that have been discussed in the
past, I'm genuinely searching before I click the compose button and not
finding anything!

I'd like to see this implemented, at least for greater/less than (-or equal
to).

    a < b < c
    a <= b <= c

Desugars to

    a < b && b < c
    a <= b && b <= c

For a real-world example

    var pos = element.getBoundingClientRect(),
         inView = 0 <= pos.left && pos.left <= window.innerWidth && 0 <=
pos.top && pos.top <= window.innerHeight;

Could be rewritten as

    var pos = element.getBoundingClientRect(),
         inView = 0 <= pos.left <= window.innerWidth && 0 <= pos.top <=
window.innerHeight;

There's a lot to be said for readability, and each operand needs only be
evaluated once, so it could help avoid the need for creating variables to
store the result of a function or a getter (or prevent the need for either
to be invoked more than once).

It's also supported (as the title suggests) by Python [1], Perl 6 [2] and
CoffeeScript [3].  Those languages support chaining the equality operators
too.

It's potentially a breaking change, because

0 < 1 < 1

evaluates to false in current implementations because

(0 < 1) < 1

However, I think we'd be hard pressed to find code like this with
greater/less than or equality operators.

[1] http://docs.python.org/2/reference/expressions.html#not-in
[2] http://en.wikipedia.org/wiki/Perl_6#Chained_comparisons
[3] http://coffeescript.org/#comparisons
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to