DIP1000: Walter's proposal to resolve ambiguity of ref-return-scope parameters
Nick Treleaven
nick at geany.org
Sat Nov 27 11:10:42 UTC 2021
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`.
> And D `ref`, no matter what, I hate it.
Not helpful without giving a reason.
> A '&' is `Ok`,why not `use` it?
Because:
1. `ref` is not part of the type, so it is used less often and we
don't need a sigil for it. It should stand out, it's important.
2. `&` is already an operator, it's best not to overload sigils.
3. C++ `&` (as a type constructor) is different from D `ref`
semantically, so we should not use the same syntax to avoid
introducing bugs when porting code from C++.
> There are too many 'attributes', can we delete? I'm writing
> functions, not `attrs`.
If we are to support checked memory safety we need more
attributes than C++, which doesn't support it. In general
attributes could be inferred when the function body is there, but
I think that is only implemented for templates ATM. Perhaps it
would impact compile-times.
More information about the Digitalmars-d
mailing list