Konrad Hinsen wrote:
> What I am really looking for is something like a safer version of
> conditional compilation via the C preprocessor. Something like the
We are having similar problems with the inner-loop electrostatics code in our
MD program. The requirement is to support several different
shifting/splitting functions (for smooth cutoffs), sometimes correcting
results of full electrostatics calculations, and three calling modes (one
list, two lists, two items). Since this is also the major contributor to
runtime, we can't use any indirection.
Currently this is implemented as a bunch of relatively legible preprocessor
code that allows the entire algorithm to appear in one definition. Every
possible combination is compiled and the desired options selected at runtime.
Some type of package along the lines of Konrad's outline would significantly
simplify this problem. In our case, a more powerful preprocessor would
probably do the trick. Perhaps something like "runtime templates"...
typedef enum { beef, chicken, fish } foodtype;
template
< choice foodtype ft, choice bool kosher > // compiles 3 * 2 = 6 versions
food* make_a_meal
( int numberOfDiners )
{
choice ( kosher ) < check label ... >
choice ( ft == chicken ) < cook well done ... >
choice ( ft != chicken ) < cook rare ... >
}
// at runtime!
foodtype myfood = beef;
int jew = 0;
make_a_meal<myfood,jew>(1);
// store the decision
make_my_meal = make_a_meal<myfood,jew>;
Any suggestions as to how to best do something like this?
-Jim
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:05 EST