opStarAssign?
0ffh
frank at frankhirsch.youknow.what.todo.net
Fri Nov 23 10:51:02 PST 2007
Janice Caron wrote:
> On 11/23/07, 0ffh <frank at frankhirsch.youknow.what.todo.net> wrote:
>> Janice Caron wrote:
>>> My preference would be to have the compiler rewrite
>>> *p += n;
>>>
>>> as
>>> p.opDerefAssign(p.opDeref() + n);
>> Wouldn't "p.opAssign(p.opDeref()+n);" be quite sufficient?
>
> I think that would end up being equivalent to
> p = *p + n;
Si.
> whereas what we actually want is the equivalent of
> *p = *p + n;
Is that so?
I'd guess that cases where both "x=y;" and "*x=y;" make sense are rare.
So overloading opAssign for the parameter type might be quite sufficient.
> but I could be wrong. Maybe it depends on what we consider opAssign
> ought to be doing. In any case, we /do/ have opIndexAssign(), so
> opDerefAssign() ought to exist by analogy.
Well it's good that you know what ought to be - I'm sure I don't. ;-)
regards, frank
More information about the Digitalmars-d
mailing list