opUnaryAssign

Quirin Schroll qs.il.paperinik at gmail.com
Wed Jul 3 10:43:14 UTC 2024


Index operators (e.g. `obj[i]`) have special overloads so that 
they hook assignment: `obj[i] = rhs` lowers to 
`obj.opIndexAssign(rhs, i)`. Why not back-port this to 
dereferencing? `*obj` lowers to `obj.opUnary!"*"`, which, to be 
assignable, must return by reference. Why not add 
`opUnaryAssign(string op)` which can hook, in principle, `+obj = 
rhs`, `-obj = rhs`, `~obj = rhs`, `*obj = rhs`, `++obj = rhs`, 
and `--obj = rhs` (of which I expect only `*obj = rhs` to be used 
regularly).


More information about the dip.ideas mailing list