Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!shlump.nac.dec.com!jareth@enet.dec.com!edp From: edp@jareth@enet.dec.com (Always mount a scratch monkey.) Newsgroups: comp.sys.handhelds Subject: Re: OBGET and EXGET Message-ID: <12073@shlump.nac.dec.com> Date: 31 May 90 03:44:28 GMT Sender: newsdaemon@shlump.nac.dec.com Organization: Digital Equipment Corporation Lines: 32 Here's an example of why OBGET and EXGET are insufficient. Suppose you are examining an expression and want to know (in a program) what the arguments to a MOD function are. You might have an expression of the form 'MOD(B*C,D)' or 'MOD(B,MOD(C,D))'. Are the arguments to the first MOD function B*C and D or are they B and MOD(C,D)? Well, your program might do OBGETs and EXGETs and try to figure out the difference. But the results are nearly identical for the two expressions: If you use OBGET to get any object from the two expressions, you'll get the same type of object in each case -- both expressions have operator, variable, operator, variable, variable, in that order. If you use EXGET and look at the size of the result, you'll get the same numbers for both expressions -- 5, 1, 3, 1, and 1. Now your program could figure out the difference between B*C and MOD(C,D) by performing further analysis. But that's going to be messy. You'd have to do a tree traversal to analyze an algebraic expression anyway, but this is more involved than a straightfoward traversal. Some analysis routine calls itself to figure out what 'B*C' or 'MOD(C,D)' looks like, and then it reports that to its caller, which uses that to figure out whether the other argument was D or B, except that could also involve analysis, et cetera. This isn't a clean algorithm. OBGET and EXGET don't analyze algebraic expressions the way the expressions themselves are structured. OBJ-> does. Also, having APPLY makes it easier to put expressions back together. On the 28, it is necessary to convert to strings and fiddle with them in order to reconstruct an algebraic without evaluating it (which could cause unwanted substitution of variables or premature calculation of functions of constants). -- edp