trustedtomato / proposal-partial-expression

Function partial application, operator partial application and all that fun stuff.
10 stars 1 forks source link

What if in ternary operator? #2

Closed saschanaz closed 6 years ago

saschanaz commented 6 years ago

x => x ? x : x is a weird code but still is valid.

If we use ? it becomes: #? ? ? : ? which is super weird.

trustedtomato commented 6 years ago

Well, that code actually translates to a SyntaxError: illegal character because # has higher precedence than the ternary operator, so it would be (x => x) ? ? : ?. I think you meant #(? ? ? : ?), and the arrow function equivalent would be (x,y,z) => x ? y : z. And I don't think that looks too weird. But if you do, you could write #((?) ? (?) : (?)) or #(?0 ? ?1 : ?2). I think with syntax highlight it would be clear in the original case too.