Programmatically defining a global variable in a new module

Thanks for your explanations and sorry for not having much of an answer so far. I guess I am still a bit confused we you need/use global variables and cannot pass the values via function arguments. To make this more explicit: You could generate a stuct that just includes every parameter you need and then pass that to every function. Then instead of accessing the global, you just access the struct’s slot. I don’t see why that should not be possible.

Also just in case it escaped your attention so far: there are so-called generated functions which fill a somewhat different niche than macros but can be very powerful for code generation. One way to implement a ‘compiler for yamls’ could be to parse the yaml and from the data build a type structure which you then feed into a generated function which constructs the actual code to be executed from the information in the type.

2 Likes