I can't say what the best plan is, but here is a possibility.
It restricts the usage of some facilities.
We can recommend some conventions.
1. Special names for pattern variables.
These names can be defined exactly once, and are used only in
the file in which they are declared. And only in that one file.
"true" pattern vars all end in _. (This resembles WRI's Mathematica, sort
of).
other pattern vars look like name_pred or name_predabbrev.
So you do
matchdeclare([a_,b_],true, c_nz,nonzero, d_fox, freeof(x)).
2. All matchdeclares are at the top of the file in which they occur,
before any uses. Or at least clearly ahead of any possible use of the
names they declare.
3. A file that does matchdeclares (as is the case for ALL files that
could be batch-loaded), should remove all properties that might be left
over from a previous loading of that file. That is,
kill(a_,b_, .....)$
matchdeclare([ a_ ..............)
This way you can read the whole file a second time, and there is less chance
that something left-over from your previous attempt, will be messing up your
environment and causing bugs.
Maybe there are some other issues that can be addressed this way.
Historical note. You might wonder why there are these relatively clumsy
syntactic
constructions. Why is it
defrule(r1,a,b) rather than, say,
r1: a->b ?
why is it matchdeclare(a,pred) instead of, say
a ::: pred ?
Answer: Joel Moses (my thesis advisor) said no, when I proposed such
syntactic things
for Macsyma. (Syntax like this was already in another language that had been
developed at CMU, Formula Algol, but I don't know if that influenced Moses.
I suspect
that he thought that the syntax was fixed (by Bill Martin) and we shouldn't
be
opening that up for reconsideration.)
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Neilen Marais
> Sent: Friday, September 15, 2006 3:53 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] Vector Identities, Redux and more questions
>
> Hi
>
> On Thu, 14 Sep 2006 11:47:30 -0700, Richard Fateman wrote:
>
> > The simplest solution seems to be to never re-bind or re-set global
> > names, which
> > is of course hard to enforce, but makes all these issues moot: x
> > evaluates to x,
> > for all x involved.
>
> Having read this, and also Robert's post, I'm a little
> confused as to what would be the best plan. If I am putting
> the vector identities into vect.mac, what would be the best
> process for doing the matchdeclare and defrule bits? What is
> the current "best practice" so to speak?
>
> Thanks
> Neilen
>
> --
> you know its kind of tragic
> we live in the new world
> but we've lost the magic
> -- Battery 9 (www.battery9.co.za)
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>