(Just a quick post from work. Lost the thread, sorry, so it's not a
f'up.)
 
Why not use +=, -=, *=, /=, etc.? Arithmetic operators would take just 2
arguments and mutate the first. I always used this technique for
implementing "value-ish" classes in C++:
thing operator +(thing lhs, thing rhs) {
    return new thing(lhs) += rhs;
}

This is really pretty much the same problem.
 
Current add-in-place op becomes:

# P3 = P4 + P5
P3 = P4 # (copy)
P3 += P5

Add-in-place to a global becomes:

; $::whatever += P4
fetch_global P3, "whatever"
P3 += P4

Chained expressions become:

# P3 = P4 + P5 + P6 + P7
P3 = P4 # (copy)
P3 += P5
P3 += P6
P3 += P7

I can see generating this syntax from an AST without completely
inordinate pain. It's not as convenient as a temp-making addition (Px =
Py + Pz) operator would be, but it also solves the modify-in-place
problem (since PMCs have reference semantics). So long as the x=
operators are also available for native types, so that the the same AST
traversal algorithm can work for all register types.
 
-- 

Gordon Henriksen
[EMAIL PROTECTED]

Reply via email to