printf() metaprogramming challenge

Radu void at null.pt
Fri May 24 12:25:19 UTC 2019


On Friday, 24 May 2019 at 12:14:09 UTC, Petar Kirov [ZombineDev] 
wrote:
> On Friday, 24 May 2019 at 09:52:58 UTC, Radu wrote:
>>
>> Yes, good point! I forgot about this trick.
>
> Best verified on d.godbolt.org. Compare:
>
> * https://d.godbolt.org/z/E8aoBg - compiles without -betterC, 
> generates a ton of bloat
>
> * https://d.godbolt.org/z/GGh9c1 - same, but doesn't compile 
> with -betterC
>
> * https://d.godbolt.org/z/mPQMcc - compiles with -betterC
>
> * 
> https://run.dlang.io/gist/run-dlang/1caf15c8c7dded16ba812353361feda9 - what I would like to write, but currently produces too much bloat and doesn't work with -betterC
>
> The examples above, were inspired by 
> https://twitter.com/Cor3ntin/status/1127210941718962177. I 
> wanted to check how D with -betterC would compare to C++23+ 
> w.r.t code gen (bloat).

I used the same method to generate C header files for a betterC 
library, I know it works and doesn't produce runtime bloat.

To bad it is something you forget, i.e. it is not obvious :)


More information about the Digitalmars-d mailing list