?? and ??= are short-circuiting, they do not fit into a eager evaluation calling convention.

Actually, that isn't even the worst issue. Since operators aren't first
class, the desugaring could wrap arguments in (arrow) functions
at the operator call sites (I've got a variant of infix.js that does this, and it can handle ??).

Unless we can limit that to non-strict argument positions, the
inconvenience of forcing evaluation (exactly once) spreads to
all operator definitions, though.

However, that does not help with defining assignment operators,
because I don't know how to pass a Reference to or from a function.

One solution would be to inline the operator definitions at the call sites. But that would turn a simple desugaring into a non-trivial transformation. And we'd be partway towards macros..

The other solution would be a way to pass References around,
but the last time I raised the issue of reifying References I was told that some engines could not easily support that, iirc.

Are macros really the only way to get around JS's peculiarities
when trying for user-defined operators and control structures?
And how far away are they?

Claus

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to