suggestion: mapping symbolic infix ops to binary functions

Claus Reinke claus.reinke at
Wed Jul 25 01:06:04 PDT 2012

> Are macros really the only way to get around JS's peculiarities
> when trying for user-defined operators and control structures?

Argh - I just noticed that even macros won't be sufficient.

Assuming we had function-like definitions that inlined/expanded
their bodies at their call sites, textually inserting their arguments. 
That would be sufficient 

- for short-circuiting operators '??'
- for simple assignment operators '='

but would not be sufficient 

- for combinations of short-circuiting and assignment '??='
    lhs ??= default_value;  // lhs = lhs ?? default_value

At least, I can't think of a way to avoid reevaluating the left
hand side operand - if I assign it to a temporary variable, it
no longer is a valid left hand side for an assignment.

So, unless I'm mistaken, we will need to deal with References
at some point, or we won't be able to express in user-code
what we can express in ES-spec language.


More information about the es-discuss mailing list