Configuring Meta-Programming
Dieter Schön
dieter@REDACTED
Sat Jan 30 12:27:10 CET 2021
Hi Mark,
so instead of each user configures his/her environment, you will have to
build a bespoke
app for each user.
You will have to know the desired configuration for each user, and build
a custom version
for each variant.
The technical part is relatively easy, I think. The parameters can be
implemented as
-define(ParamX, ValueY).
Maybe add some -ifdef, if the configuration is complex.
And, from a CM perspective, I would definitely have everything in
version-controlled files.
No ad-hoc commandline switch-triggered artifacts.
Also, for runtime introspection, add a function which outputs the
configuration parameters
of the module.
From my experience, in a commercial environment,
you should be most concerned how to be able to reliable and reproducible
build a version. And to be able to track which versions are in use where.
kind regards,
dieter
On 29.01.21 15:25, Mark S wrote:
> Hello,
>
> I'm looking for advice on how to configure code generated at compile
> time. My current solution reads the configuration values from a file,
> but the feedback I received indicates that requiring users to create
> and maintain a config file, in order to use this library, will at the
> very least, severely limit its usefulness.
>
> Is there another way to introduce configuration values at compile
> time? Is there a library you can point me to, that has resolved the
> same issue differently?
>
> Specifically, I created code that generates a module, containing a
> custom Cyclic Redundancy Check (CRC) calculation function that
> utilizes a CRC look-up table. Creating the function and the look-up
> table requires specifying the bit width, polynomial, initial value,
> final XOR value, and whether the input and output values are reflected
> or not.
>
> To generate the code module, I used Ulf Wiger's parse_trans library.
> In particular, ct_expand:term() to generate the look-up table, and
> codegen:gen_module() to generate the code and finally calling
> merl:compile() to compile the abstract syntax tree, generated by
> gen_module().
>
> Thanks,
>
> Mark Sebald
More information about the erlang-questions
mailing list