C to D

bachmeier no at spam.net
Fri Oct 20 15:07:35 UTC 2023


On Wednesday, 18 October 2023 at 23:09:11 UTC, Walter Bright 
wrote:
> On 10/18/2023 11:25 AM, bachmeier wrote:
>> On the other hand, there's no reason to manually convert C to 
>> D.
>
> I manually converted the D backend from C to D. It didn't take 
> long - mostly because:
>
> 1. I'd already removed my oh-so-brilliant C preprocessor 
> metaprogramming
>
> 2. A bit of global search/replace handles quite a lot
>
> Of course, the result still looks and acts like C code.

Oh I can do better than that. I can drop foo.c in the project 
directory and call all of those functions without doing anything 
else. Code conversion is usually pointless, because the functions 
in the .c file work, they're documented, the edge cases have been 
handled, it's all been tested, and I can update by dropping an 
updated foo.c in the project directory. If I have the urge to 
convert, I'm going to do a full rewrite of the code so it's easy 
to read and easy to work with, like D code is supposed to be.


More information about the Digitalmars-d mailing list