study: use checkedint as a drop-in replacement of native long

Paul Backus snarwin at gmail.com
Wed Mar 24 17:29:10 UTC 2021


On Wednesday, 24 March 2021 at 17:23:00 UTC, Q. Schroll wrote:
> On Tuesday, 18 August 2020 at 01:23:01 UTC, Andrei Alexandrescu 
> wrote:
>> Requiring user-defined assignment to `return *this;` was goofy 
>> in C++. Requiring user-defined assignment to `return this;` is 
>> goofy in D. Assignment should return void and the compiler 
>> should take care of it.
>
> Do you mean the compiler should take care of returning *this 
> when opAssign returns void? Because there are some use-cases 
> for opAssign to return something different than `this`, but I 
> cannot remember at the moment what it was. It's a niche case.

Ideally `lhs = rhs` would always evaluate to `lhs`, as it does 
for the built-in assignment operator. But that would require a 
deprecation cycle, since, as you say, existing code could be 
relying on the current behavior.


More information about the Digitalmars-d mailing list