DIP1000: Walter's proposal to resolve ambiguity of ref-return-scope parameters

Walter Bright newshound2 at digitalmars.com
Sat Nov 27 18:27:43 UTC 2021


On 11/27/2021 3:10 AM, Nick Treleaven wrote:
> On Saturday, 27 November 2021 at 01:10:37 UTC, zjh wrote:
>> `C++` references, which look complicated, are actually simple.
> 
> Try reading the C++ spec, you will see the rules are far more complicated than D 
> `ref`.

C++'s & for ref is part of the type system, but it is such a special type that 
it messes with every aspect of the type system.

This comes about because & can only appear at the "head" of a type (a "pointer 
to ref to int" cannot be declared), and there are many, many rules saying when 
the ref type is significant and when it is skipped.

D made the better decision to have `ref` be orthogonal to the type.


More information about the Digitalmars-d mailing list