suggestion: mapping symbolic infix ops to binary functions

Claus Reinke claus.reinke at talk21.com
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
>   obj.id op= val  ~~~> do { let $t = obj; $t.id = $t.id 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.

Thanks,
Claus


 


More information about the es-discuss mailing list