DTD for maxima internal form



> The equivalent to a DTD is available in lisp as the function READ.

In XML/SGML, just as in Lisp, you can read tree-structured data without
a DTD/Schema.  The syntax is of course much more verbose than
S-expressions: instead of 

   ((mplus simp) x y)

you might have something like

   <mplus simp="t"><var>x</var><var>y</var></mplus>

What a DTD/Schema allows you to do is to specify restrictions on
structures, so as to disallow -- at read time -- things like

   (mplus x (((x) 1) 3))

or for that matter

   (x + y)

There is no standard way to do this in Lisp.  You may or may not
consider  this useful, but it is *not* the same thing as the Read
function.

Lisp validates almost nothing at read time, leaving validation to
execution or compilation time.  Read is perfectly happy to read in 

     (cond (lambda (x . y) y))

which is a perfectly fine piece of list structure, though an illegal
Lisp expression (modulo redefinition of 'cond' etc.).  After all, you
never told Read it was reading in an expression as opposed to some
random tree-structured data.

This makes it easier to do some things (to manipulate illegal programs,
for example) and harder to do others (any code that manipulates programs
has to be aware of the possibility that they may be malformed).

--------------------------

<rant>

Stepping back from this small technical point, it seems to me that we in
the Lisp community ought to be absolutely ***delighted*** that XML is
making such a big splash.  Sure, it is bloated.  Sure, it has design
flaws.  Sure, it has warts.  But the important point is that it is
bringing most of the advantages of Lisp-like data structure, namely tree
structure, human readability, universality, openness, and non-static
definition, to the larger world.  The alternative to XML in the real
world is not s-expressions -- it is relational tables and
comma-separated values and proprietary binary spreadsheet formats
(Excel) and unparenthesized postfix (Postscript) and horrible macro
languages (Tex -- well, I threw that in to provoke the physicists -- in
reality of course it has minuscule presence in the real world) and all
that stuff.

There are of course intelligent ways to use XML (as an interchange
format where efficiency isn't paramount, as an archival format, etc.)
and foolish ways to use it (as an internal format, as a data definition
language, etc.).  Just like s-expressions.  It would be foolish to use
the ASCII form of s-expressions as an internal format, after all....

</rant>

      -s