Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!csd4.csd.uwm.edu!bionet!apple!usc!merlin.usc.edu!nunki.usc.edu!jeenglis From: jeenglis@nunki.usc.edu (Joe English) Newsgroups: comp.lang.c Subject: Re: evaluating math w/o recompile Message-ID: <5124@merlin.usc.edu> Date: 17 Sep 89 06:44:27 GMT References: <11068@smoke.BRL.MIL> <225800223@uxe.cso.uiuc.edu> Sender: news@merlin.usc.edu Reply-To: jeenglis@nunki.usc.edu (Joe English) Organization: University of Southern California, Los Angeles, CA Lines: 42 zador-anthony@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@nunki.usc.edu