[Semi OT] Language for Game Development talk

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 20 01:38:48 PDT 2014


He also proposes of removing most or all implicit type 
conversions in his language, like bool->int.

D allows code like:

bool foo() { return true; }
void bar(int x) {}
void main() {
     bar(foo());
}


In past, removing implicit conversions from D forced you to write:

bar(cast(int)foo());

That is not much safer than having implicit conversions because 
cast() is a sharp powerful tool. In D programs the usage of 
cast() should be minimized as much as possible.

But if we keep disallowing implicit conversions, but we introduce 
a second kind of static cast that only work if the conversion is 
lossless, then we have code like (currently this is allowed in D 
because the int() syntax rides on the implicit conversions. So 
the semantic is a little different):

bar(int(foo()));

You also need suffixes to express most types with literals (like 
10u8 for an ubyte, or 'c'd for a dchar), to code in a more handy 
way.

Perhaps this new situation (no implicit conversions, plus two 
kinds of casts, and few extra literals) is safer than the current 
D situation (and I think no C code gains a new working meaning in 
this new situation).

Bye,
bearophile


More information about the Digitalmars-d mailing list