evaluating math w/o recompile
Joe English
jeenglis at nunki.usc.edu
Sun Sep 17 16:44:27 AEST 1989
zador-anthony at CS.YALE.EDU (anthony zador) writes:
>I would like to be able to specify the form of the function f
>at *run time* (no recompiles). That is, i would like
>to place a line of math
>in some file and have the program read it in and evaluate it.
How about writing a set of math interface
functions that take, instead of a fixed set of parameters,
an argv/argc pair? I'm doing something like that right
now in a report generator I'm writing:
enum valuetype { vInt, vFloat, vString ... };
typedef struct {
enum valuetype tag;
union {
int ival;
double fval;
char *sval;
...
} datum;
} value;
Then for the interface function:
value somefunc(int argc,value *argv)
{
/* use argc parameters from the argv array. Type-checking
of arguments is done by the parser & function
lookup table.
*/
}
If you don't need full generality, you can use
'double *argv'.
--Joe English
jeenglis at nunki.usc.edu
More information about the Comp.lang.c
mailing list