3 ms·
> D's design is based around the idea that semantically valid C will compile in D AFAIK it's that code which compiles in both c and d should have the same beha
by earenndil 7y ago
> D's design is based around the idea that semantically valid C will compile in D
AFAIK it's that code which compiles in both c and d should have the same behaviour; not that c code should necessarily compile in d. Examples of c that don't work in d are trivial.
> there are tools to convert C to D (As used in the dmd compiler backend (which dates back to the 80s I believe, but is now in a tasty form of spaghetti D)
Dmd's backend was ported by hand. What tools are those? I know there are tools to convert header files, but I don't know of any that actually convert code.
- mhh__ 7y agoSemantically valid as in valid D, not valid C. > Dmd's backend was ported by hand I stand corrected then. Visual D has one cpp2d built in, which I assumed was used
- nicwilson 7y ago> Dmd's backend was ported by hand. Not quite, the c++ source was massaged to be free of weird corner cases of the grammar and preprocessor (e.g. enforcing no spaces between '#' and the preprocessor keyword) and then a tool called magicport was used to convert the frontend in one shot. The backend was mostly converted by "hand" (i.e. grep after some more massaging). There are several tools to translate headers though dstep[1] and dpp[2] come to mind [1]: https://github.com/jacob-carlborg/dstep https://github.com/jacob-carlborg/dstep [2]: https://github.com/atilaneves/dpp https://github.com/atilaneves/dpp
- WalterBright 7y agoMagicport was used to convert the front end. The back end was done by hand, one file at a time (and passing the test suite after each file). Most of the conversion was "replace -> with ." and then fixing whatever the compiler complained about.