On Tuesday, 3 April 2018 at 01:31:12 UTC, Laeeth Isharc wrote:
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)
{

}

You can do that in D too - see Atila's concepts library.

interface IFoo {
    int foo(int i, string s) @safe;
    double lefoo(string s) @safe;
}

@implements!(Foo, IFoo)
struct Foo {
    int foo(int i, string s) @safe { return 0; }
    double lefoo(string s) @safe { return 0; }
}

// doesn't compile
/*
@implements!(Oops, IFoo)
struct Oops {}
*/

Reply via email to