suggestion: mapping symbolic infix ops to binary functions

Claus Reinke claus.reinke at
Wed Jul 25 02:00:03 PDT 2012

>> 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.
> The trick is to specialize as all competitive JS engines do today to 
> avoid references:
>   id op= val  ~~~>  id = id op val
> op= val  ~~~> do { let $t = obj; $ = $ op val }
>   obj[x] op= val  ~~~> do { let $t = obj, $u = x; $t[$u] = $t[$u] op val }
> The macro system just needs to be able to specialize on the various 
> legal lvalue special forms.

Nice! Obvious, in hindsight, but somehow I never thought of that.



More information about the es-discuss mailing list