D

N N_member at pathlink.com
Sun Apr 16 08:25:32 PDT 2006


I love the idea of D language.
But I think it misses some usefult points.

1.
There is no compile-time reflection.
E.g. one could write:
[d]
class a
{
void f() {}
int i;
}

int a_methods = a.methods.length;
bool has_a_f = a.has_method(f);
int a_variables = a.variables.length;
bool has_a_i = a.has_variable(i);

// Or even
class b
{
void g();
}

type a_f_type = a.f.type;
foreach(auto b_f_type; b.methods)
if(a_f_type == b_f_type)
b.b_f_type(); // call b.g
[/d]

2.
Make all postfix:
[d]
// instead of
typeof(a) x = 1;

// write:
a.type x = 1;

// instead of
int a = cast(int)('a');

// write:
int a = 'a'.cast<int>;
// or if we have static_cast :)
int a = 'a'.static_cast<int>;
[/d]

3.
Extensible Metainformation:
E.g.
[d]
class a
{
meta
{
bool is_a = true;
}
}

meta // For all types
{
bool is_a = false;
}

a x;
int y;

static_assert(x.is_a == true);
static_assert(y.is_a == false);
[/d]

4.
Make built-in types likely to object types.

5.
'auto' keyword problem resolution.
auto x = new a(); // auto type, or auto destructor ?

E.g.:
[d]
auto a x = new a(); // destrutor
var x = new a(); // auto type
auto var x = new a(); // auto type + destructor
[/d]

6.
C syntax for templates.
It's so natural.

7.
More casts.
E.g. 
static_cast
dynamic_cast
reinterpret_cast // make it safe, error if size of arguments is different
pointer_cast


8.
implicit 'new'.
E.g.
[d]
a x(...); // same as , a x = new a(...)
// same as , auto x = new a(...)

int[] q(1, 2, 3, 4, 5); // same as int[] q = new int[](1, 2, 3, 4, 5);
[/d]

9.
Will be continued. :)

Thank you for attention.





More information about the Digitalmars-d-learn mailing list