November 27
On 11/27/2021 3:10 AM, Nick Treleaven wrote:
> 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.

Any case where the source to the function is required, such as template functions and `auto` return functions, gets their attributes inferred.

The reason is for consistent behavior if just the function declaration is visible, rather than the function definition (i.e. body). The decision is done by the canInferAttributes() function.
November 27
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.
November 27
On 11/27/2021 6:35 AM, russhy wrote:
> consistency!
> 
> 
> we have ``int*`` for pointers
> 
> let's use ``int&`` for references
> 
> 
> consistency > everything else, i don't use ref because i hate typing it, same for immutable

There's almost nothing consistent about the way & is in C++.
November 28
On Saturday, 27 November 2021 at 18:27:43 UTC, Walter Bright wrote:
> 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.

i can see understand that point

i personally stick to pointers only in my codebase, because i like simplicity, i didn't even use & back when i was using C++, it always felt dirty anyways

Next ›   Last »
1 2 3 4 5 6 7 8