suggestion: mapping symbolic infix ops to binary functions
claus.reinke at talk21.com
Mon Jul 23 13:57:42 PDT 2012
> ?? 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?
More information about the es-discuss