Re: Programming
- To: mathgroup at smc.vnet.net
- Subject: [mg2835] Re: Programming
- From: fateman at peoplesparc.cs.berkeley.edu (Richard J Fateman)
- Date: Sat, 23 Dec 1995 03:19:06 -0500
- Organization: University of California, Berkeley
In article <4bammu$cgv at dragonfly.wri.com>, Robert Villegas <villegas at buka.wri.com> wrote: >In article <4b8583$app at dragonfly.wri.com> Jack Goldberg <jackgold at umich.edu> >writes: .... The difficulty faced here is not knowing in what order Mathematica applies rules. It orders them in some way, but other than trying to do the more specific before the more general, it is not specified. If you have 2 rules Foo[expr_]:= .... try one thing Foo[expr_]:= .... try something else, and do ??Foo it would be nice if the rule set displayed gave you a hint as to how it was going to work, and also if you could rearrange these rules. I think, however, you cannot. The application of these rules, especially if one of them is a built-in rule or function, is tricky, especially if the application is recursive. The Macsyma system actually has what Robby tries to implement as two commands tellsimp( foo(x), bar(x)) if this rule is to go before the built-in one and tellsimpafter(foo(x), bar(x))...otherwise. To see another solution, consider looking at The common lisp object system (CLOS) which has numerous ways of composing methods, before, after, around, and more complicated ways. Perhaps WRI should look at these for future extensions of Mathematica. -- Richard J. Fateman fateman at cs.berkeley.edu http://http.cs.berkeley.edu/~fateman/