On Monday, 2 April 2018 at 20:19:17 UTC, rumbu wrote:
On Monday, 2 April 2018 at 18:54:28 UTC, 12345swordy wrote:
- Only structs are used, no classes;
- .NET collections are replaced by native collections that
manage their own memory
- No code that would trigger GC is allowed
- Compiler is aware of Unity features and is able to explore
SIMD, by doing auto-vectorization, and transparently
transform structs fields into optimal representations
The struct type in C# is more versatile than the D's
equivalent, mainly because of the fact that you can inherit
interfaces. You can have template constraints in D but this is
not as user friendly as a struct interface.
So in C# you can write code like this:
interface IRange<T>
{
void popFront();
bool empty();
T front();
}
struct MyRange<T>: IRange<T>
{
//implementation
}
void foo<T>(IRange<T> someRange)
{
//do something with someRange even it's a struct
//this includes code completion and other IDE specific stuff.
}
In D, template constrains are not very clean and they not have
IDE support:
void foo(T)(T someRange) if (isInputRange!T)
{
}
Worth mentioning is that doing this necessarily causes the struct
to be boxed. I would not be surprised if they ban structs
inheriting from interfaces.