[OT] C vs C++
JG
someone at somewhere.com
Sat Sep 10 17:05:18 UTC 2022
On Saturday, 10 September 2022 at 13:58:51 UTC, H. S. Teoh wrote:
> On Sat, Sep 10, 2022 at 05:57:53AM +0000, JG via Digitalmars-d
> wrote:
>> > [...]
> [...]
>> [...]
>
> In fact, this is precisely the advantage of separately
> generating the code: you can examine the generated .d file for
> yourself and see precisely what was generated.
>
>
>> [...]
>
> Template-heavy / mixin-filled code is a nightmare to debug, if
> they were not written to be debuggable. Because you cannot see
> what's the final code that the compiler compiles. Whereas
> generating a .d file as a separate compilation step lets you
> examine the file yourself and find where the bug is.
>
>
>> [...]
>
> That's because the diet templates' code was written to generate
> these nice error messages. When you run into a case the authors
> didn't anticipate, good like trying to debug the heavily-nested
> diet code...
>
> Of course, an error in a separately-generated .d file may not
> be trivial to debug either, but presumably you also wrote the
> helper utility that did it, so by seeing the error in the
> generated .d file, it would guide you to look at the section of
> the helper utility responsible for generating that bit of code,
> and you can go from there.
>
>
>> [...]
>
> This is another disadvantage of using templates/mixins:
> external tools have to be able to parse templates and magically
> infer what exactly is the mixed-in string, in order to help
> you. An externally-generated .d file is just regular D code,
> you just use standard code utilities on it and you're ready to
> go.
>
>
> T
I agree in part with what you say, perhaps I will try it again
sometime.
My last attempt was a few years ago being fed up writing go and
not having templates. So I wrote a program that transformed "my
templated go" into go.
For small things it was fine but when I tried to use it more
seriously I
found trying to bug fix it painful. (In case someone feels the
need to inform me that go has generics now - I am aware of that.
I tried them I think they are not too great).
More information about the Digitalmars-d
mailing list