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

Reply via email to