D is the best tool for this!!! How do we tell them??
Walter Bright
newshound2 at digitalmars.com
Tue Aug 6 01:24:32 UTC 2024
On 8/4/2024 3:06 AM, Guillaume Piolat wrote:
> - Some C headers like j40.h and miniz.h use the "switch-based coroutine" and
> exploit the fact the case label can be anywhere to create push parsers. Rust
> match doesn't allow labels anywhere, but D does so you can do the switch-based
> coroutine. Example:
> https://gist.github.com/mrtrizer/a14c033a054c191d9d23bfa516ad8107
> At least this case is easy in D.
It's one reason why pattern matching in D will be a construct separate from the
switch statement.
> - Some C headers like j40.h and stb_image_resize2.h use header self-include to
> change macros and have some sort of templates. A single C header can include
> itself many times (imagine the poor lexer). When translating this, it can be
> tempting to just expand however the translated code may make more sense if done
> with a policy-based template and `mixin`.
ImportC can do translations of C to D, but not translations of non-trivial
preprocessor metaprogramming.
Problems aside, reports from the field are that ImportC can do maybe 90% of the
job, the rest by hand. Still a big win.
My experience hand-translating C to D is about 1000 lines per hour.
More information about the Digitalmars-d
mailing list