P
pinkfloydhomer
We might use the normal preprocessor something like this
#define WIDTH 42
#define HEIGHT 100
#define AREA (WIDTH*HEIGHT)
To have "42*100" is inserted in the code whereever AREA is used. But
does an evaluating preprocessor exist that can do some evaluation on
expressions so that AREA becomes 4200?
I know that most compilers will figure this out themselves anyway.
And I know that I should use a const instead for this kind of thing.
But in general (for instance with old (C) compilers that don't have
const, or compilers that don't optimize very well), it would be nice to
_know_ that an expression is evaluated before compile-time and runtime.
In general, it would be nice to have a simple and clean turing complete
language for compile time evaluation. I guess I can easily make a
simple but powerful preprocessor in Python that can do this, also for
C/C++ code. But maybe it already exist?
/David
#define WIDTH 42
#define HEIGHT 100
#define AREA (WIDTH*HEIGHT)
To have "42*100" is inserted in the code whereever AREA is used. But
does an evaluating preprocessor exist that can do some evaluation on
expressions so that AREA becomes 4200?
I know that most compilers will figure this out themselves anyway.
And I know that I should use a const instead for this kind of thing.
But in general (for instance with old (C) compilers that don't have
const, or compilers that don't optimize very well), it would be nice to
_know_ that an expression is evaluated before compile-time and runtime.
In general, it would be nice to have a simple and clean turing complete
language for compile time evaluation. I guess I can easily make a
simple but powerful preprocessor in Python that can do this, also for
C/C++ code. But maybe it already exist?
/David