MathGroup Archive 1999

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

Search the Archive

Re: An open letter

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16601] Re: [mg16540] An open letter
  • From: David Withoff <withoff>
  • Date: Wed, 17 Mar 1999 23:55:07 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

I hope that you will get some useful programming suggestions in response
to your evaluation control examples (an integration-by-parts function, etc.).
I can comment specifically on your last paragraph:

> I am fairly confident that this type of problem can be solved by 
> a judicious combination of "holds"  and "releaseholds" and "evaluates".
> The fact remains that it is something of a challange.  It shouldn't
> be. I say this because at least one other CAS has an easy means for
> accomplishing this goal.
> 
> What say yo'all?

One way to look at the underlying design question is as a choice between
single-step evaluation and infinite evaluation.  Mathematica uses infinite
evaluation, which means that applicable rules are applied automaticaly.  To
illustrate the difference between this and single-step evaluation, where
in Mathematica you can do

In[1]:= f[0] = 1; f[n_] := n f[n-1]

In[2]:= f[11]

Out[2]= 39916800

you might in a strictly single-step evaluation system see

In[1]:= f[0] = 1; f[n_] := n f[n-1]

In[2]:= f[11]

Out[2]= 11 f[11-1]

and to get the expected evaluations you might do

In[1]:= f[0] = 1; f[n_] := Evaluate[n Evaluate[f[Evaluate[n-1]]]]

In[2]:= f[11]

Out[2]= 39916800

This is an extreme example.  I doubt that there are any systems that
work this way.  Even in systems like Lisp or Macsyma, which are nominally
designed around single-step evaluation, most such evaluations happen
automatically.  The need for explicit evaluation is, however, far greater
in single-step evaluation systems that it is in Mathematica.

The design of Mathematica reflects the opinion that, in most applications
of Mathematica, evaluation is more useful than non-evaluation, and
that evaluation should therefore be the default.  In Mathematica, to
get non-evaluation, you have to override the default, such as through
use of the HoldFirst, HoldRest, or HoldAll attributes, or use of
functions such as Hold and Unevaluated.  In single-step evaluation
systems, non-evaluation is the default, and you instead have to override
the default to get evaluation.

My introduction to this and several related subjects in the theory of
programming languages was Abelson and Sussman, "Structure and
Interpretation of Computer Programs", but there are many other good
references.  I have come to the conclusion that this is an unavoidable
design dilemma.  Anyone who has programmed Mathematica for more than
a few hours has probably run into problems such as the problems that
you described, but on balance I think that Mathematica offers a decent
set of features in this regard.  The default behavior is usually what
I want, and when it isn't there always seems to be a way to get it.

Dave Withoff
Wolfram Research


  • Prev by Date: Re: An open letter
  • Next by Date: Importing PostScript files
  • Previous by thread: Re: An open letter
  • Next by thread: Re: An open letter