Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!udel!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: evaluating math w/o recompile Message-ID: <11068@smoke.BRL.MIL> Date: 14 Sep 89 21:31:05 GMT References: <7598@goofy.megatest.UUCP> <34566@apple.Apple.COM> <556@tigger.planet.bt.co.uk> <451@siswat.UUCP> <72603@yale-celray.yale.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 16 In article <72603@yale-celray.yale.UUCP> 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. >I have played around with "hoc", the high order calculator >described in the Unix Programming Environment by K&P, but that seems >like overkill for this task. Is there a simpler way? Because C expressions have to be compiled (in most C environments, anyway), there's no way to input C language pieces at run time. You could however construct a source file, invoke the compiler on it, and execute it to get the results (into a file or via IPC), assuming a decent operating system environment. The portable way to do this is to build a language translator/interpretor into your application, much along the lines of the code used in "hoc".