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).
Thread overview | |||||
---|---|---|---|---|---|
|
July 03 opUnaryAssign | ||||
---|---|---|---|---|
| ||||
July 03 Re: opUnaryAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to Quirin Schroll | On Wednesday, 3 July 2024 at 10:43:14 UTC, Quirin Schroll wrote: >Index operators (e.g. wouldnt
|
July 04 Re: opUnaryAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to monkyyy | On Wednesday, 3 July 2024 at 13:26:35 UTC, monkyyy wrote: >On Wednesday, 3 July 2024 at 10:43:14 UTC, Quirin Schroll wrote: >Index operators (e.g. wouldnt In the expression grammar, clearly
There are exceptions, e.g. binary |