www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - newbie question

reply %u <asmasm hotmail.com> writes:
does D compatibility with C restrict D from evolving ?
and if D drop this will that prevent complexity?
Sep 18 2011
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 09/18/2011 10:08 PM, %u wrote:
 does D compatibility with C restrict D from evolving ?

Binary compatibility as in extern(C) certainly does not. As to source-level compatibility, the only "guarantee" that Ds design gives is that C code will either compile as D code with identical semantics or not compile at all. The only thing that restricts a language from evolving is compatibility with the existing code base for that language.
 and if D drop this will that prevent complexity?

You mean, "does C compatibility impose additional complexity on the D language?" ? I am sure it does not, C is quite basic. And as I said, not every C program is also valid D code. That is both an advantage and a disadvantage in comparison to C++.
Sep 18 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Timon Gehr:

 As to 
 source-level compatibility, the only "guarantee" that Ds design gives is 
 that C code will either compile as D code with identical semantics or 
 not compile at all.

In practice there are few differences, try to compile this in C and D, swapping the import/include: import core.stdc.stdio; //#include "stdio.h" float a[1]; void foo(float v[1]) { v[0]++; } int main() { foo(a); printf("%f\n", a[0]); return 0; } Bye, bearophile
Sep 18 2011