MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Programming

  • To: mathgroup at
  • Subject: [mg2835] Re: Programming
  • From: fateman at (Richard J Fateman)
  • Date: Sat, 23 Dec 1995 03:19:06 -0500
  • Organization: University of California, Berkeley

In article <4bammu$cgv at>,
Robert Villegas <villegas at> wrote:
>In article <4b8583$app at> Jack Goldberg <jackgold at>  
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
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

  • Prev by Date: Re: Mathlink & Macintosh & CodeWarrior
  • Next by Date: implicit differentiation
  • Previous by thread: Re: Programming
  • Next by thread: Re: Programming