CTFE, string mixins & code generation

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Sat Jan 25 07:36:06 UTC 2020


On Friday, 24 January 2020 at 16:21:48 UTC, Jan Hönig wrote:
> I am looking for a detailed explanation or showcase regarding 
> CTFE and string mixins.
> I want to play with D a little bit regarding code generation.
> I would like to have a pseudo-AST, consisting of a few classes, 
> to represent some calculation. Think of a loop, some 
> statements, and expressions.
>
> To do that, I want to be certain that this AST can be computed 
> and generated during compile-time, with CTFE and string mixins.
>
> Are there limitations regarding CTFE (GC, global variables, 
> static variables, templates, ....)?
> Are there any limitations regarding string mixins (which are 
> not already included int the CTFE limitations)?

Back in the day I had written CTFE unittests for Protobuf 
generation.

https://github.com/JesseKPhillips/ProtocolBuffer/blob/master/source/dprotobuf/generator/dlang.d#L740

IIRC the mixin was because it needed to compile in a D1 compiler.

I don't recall why I needed these.

https://github.com/JesseKPhillips/ProtocolBuffer/blob/master/source/dprotobuf/generator/dlang.d#L20


More information about the Digitalmars-d-learn mailing list