OT: C# now has ref and const ref return
XavierAP
n3minis-git at yahoo.es
Tue Aug 6 09:54:49 UTC 2019
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref#reference-return-values
This is a good example how C# is getting very competitive not
only on the high-productivity segment (which Dlang currently
neglects relatively), but expanding into higher performance. The
only point of these new features is to enable writing C# code
that does not allocate in the GCed heap. I think D should pay
attention
See also:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref#ref-struct-types
Syntactical design-wise they have opted for total explicitness.
Everything has to be decorated ref: function declaration, return
statement, and local variable declaration at caller scope. (This
makes it look at first like it's allowing ref local variable
declarations like C++, but I understand -- haven't played with it
yet -- that in reality it's only allowed at the left side of
calls to ref return methods.) I guess this explicit approach may
be safer and works for C# since it by design doesn't have
templates/heterogeneous generics, but polymorphic/homogeneous.
Note in case you're not familiar that C# readonly means D
immutable and C# const means D enum.
More information about the Digitalmars-d
mailing list