Compile-time constants to replace preprocessor macros in configuration files? #2052
Replies: 2 comments 11 replies
-
This isn't a design that's been fully designed out yet, but metaprogramming will exist in some form, and this kind of use case would probably use let, e.g. |
Beta Was this translation helpful? Give feedback.
-
I think there is a speed and memory issue with using compile-time constants as a replacement for preprocessor macros. Preprocessor macros are evaluated before compilation, meaning that potentially a lot of code is removed before compilation. If the decision of which code to use or not is deferred to the compilation then this will have a negative impact on speed and memory while compiling. |
Beta Was this translation helpful? Give feedback.
-
I'm considering extending one of my projects with a configuration tool inspired by eCos CDL (to configure C++ programs), and, looking to the future, I'm trying to figure out how such a configuration tool is expected to work with Carbon.
In C/C++ the usual way to pass configuration data is via an
#include "config.h"
where several preprocessor macros are defined, and later the code can test for the macros presence or use the values to define the size of arrays, etc.In Carbon, which, if I got it right, does not have a preprocessor, I expect such configurations to be implemented with compile-time constants, booleans for simple yes/no choices, integer for sizes, etc.
However, I was not able to figure out how this mechanism is expected to work... :-(
Could someone provide an example how a file with such configuration constants may look like, and how it should be included in other files?
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions