Case-sensitivity goals, policy and implementation



Everyone,

I would like to present a slightly modified plan for case sensitivity in
Maxima. Even though we have already discussed this subject at great
length, I believe a little more discussion is warranted. The change in
case-sensitivity is something we should do only once, so it is important
that we end up with a plan that will stand the test of time.

First, let me state the goals of the new plan:

1) Maxima should make it as easy as possible to represent mathematical
expressions used in hand calculations.

2) Maxima's behavior with respect to case should be simple enough to
easily explain to users familiar with contemporary programming languages
and consistent with basic software engineering principles.

3) Maxima should continue to interact well with ANSI Common Lisp.

(These goals could probably be stated more clearly, but I don't think
it's worth spending a week working on wording.)

To sum up a long conversation that I do not wish to revisit, the problem
with the current implementation is that it fails to meet goal (2). The
case-guessing logic in the current Maxima can lead to surprising
behavior. One such surprise showed up just this week in seemingly minor
additions to the test suite.

Originally, I proposed a new policy whereby Maxima would be totally case
sensitive. The implementation was to involve extensive use of quoting,
e.g., |$integrate|, in the lisp source. As I recall, Raymond Toy's
reaction to this was "yuck." Having tried typing ||'s everywhere for a
while, I see his point. I now agree that this policy/implementation
combination would conflict with goal (3) above.

I would like to propose a modified policy. Maxima would be totally case
sensitive, *however* all built-in functions would be addressable as
either all lower case or all upper case. E.g., the cosine function could
be written as "cos" or "COS". "Cos", "coS", "CoS", etc. would all be
distinct functions.

I have a proof-of-concept implementation for this new policy. The
implementation modifies defun in the maxima package so that 
	(defun $foo ...)
defines the function |$foo| while executing
	(setf (symbol-function $FOO)
	   (symbol-function |$foo|))
Functions that do not start with a $ behave as usual, i.e.,
	(defun bar ...)
still defines the function BAR. This implementation allows us to
implement the new case-sensitivity policy with few modifications to the
Maxima source.

Obviously, the new policy is partially driven by the implementation. I
think the policy is a reasonable compromise allowing us to meet all
three goals enumerated above.

I ask for your comments and criticisms.

--Jim