[Issue 1596] op*Assign should return void

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 8 16:12:44 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=1596



--- Comment #10 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-07-08 16:07:37 PDT ---
>- If it's typeof(this), the AssignExpression calls this op*Assign, sets the
>lvalue to what op*Assign returns and then returns it.

That would be a _bad_ idea. On some level, it defeats the purpose of op*Assign
in the first place. There are cases where it is more efficient to do the
operation and assign in one operation. Your suggestion basically relegates to
op*Assign to being another opBinary except that it allows for the compiler to
replace a op= b with a = a op b. Assignment _needs_ to be part of the
implementation of op*Assign. That's part of the point. Yes, the return value of
op*Assign should be the same as the value as the lvalue, but getting the return
value and then doing the assignment makes op*Assign pretty much pointless. If
that were the proper way to do it, we wouldn't have op*Assign in the first
place. We'd just create op= from opBinary and opAssign. And that's _not_ what
we want.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list