DIP 1018--The Copy Constructor--Community Review Round 1
Nicholas Wilson
iamthewilsonator at hotmail.com
Sat Dec 22 08:50:26 UTC 2018
On Saturday, 22 December 2018 at 08:24:15 UTC, Johannes Loher
wrote:
> On Friday, 21 December 2018 at 14:43:50 UTC, Boris-Barboris
> wrote:
>> On Tuesday, 18 December 2018 at 14:51:39 UTC, Mike Parker
>> wrote:
>> 1). I do not like the ability to specify a mutable copy
>> source. Under no circumstance should the code like
>>
>> A a;
>> A fun()
>> {
>> return a; // lowered to return tmp.copyCtor(a)
>> }
>>
>> void main()
>> {
>> A b = fun(); // the return value of fun() is moved to
>> the location of b
>> }
>>
>> be allowed to modify the value of a.
>
> I totally agree. A copy modifying the source is very counter
> intuitive.
Modifying the source _is_ stupid, however const is transitive so
we have no way distinguish modification of the source from
modifications through indirections in the source which is useful
e.g. incrementing the reference count.
More information about the Digitalmars-d
mailing list