On 2/15/07, Douglas Crosher <dtc at scieneer.com> wrote:
> The use of strings to name operations currently seems problematic because
> 'amperchk (in suprv1.lisp) converts maxima strings into symbol names by
> effectively downcasing all characters. For example: neither "sin"(1) or
> or "SIN"(1) are equivalent to sin(1).
>
> (%i1) (postfix ("f2"), "f2"(x));
> (%o1) F2(x)
Trying this with Clisp, GCL, & SBCL, I see x f2 here.
Is the above result from a case-sensitive Lisp?
> (%i2) "sin"(1);
> (%o2) SIN(1)
> (%i3) "SIN"(1);
> (%o3) SIN(1)
>
>
> Would there be any objections to modifying 'amperchk to use the case flipping
> rules that are used for unquoted names?
>
> The proposed change is to 'casify-exploden:
> (defun casify-exploden (x)
> (cond ((char= (getcharn x 1) #\&)
> (cdr (exploden (maybe-invert-string-case (string x)))))
> (t (exploden x))))
>
> With this change:
>
> (%i1) (postfix ("f2"), "f2"(x));
> (%o1) x f2
> (%i2) "sin"(1);
> (%o2) .8414709848078965
> (%i3) "SIN"(1);
> (%o3) SIN(1)
The proposed change to CASIFY-EXPLODEN is OK by me.
That said, there are a couple of even-more-obscure points here.
(1) Maxima recognizes "f2"(x) as x f2 because &f2 has the OPR property.
(The operator-declaring functions postfix prefix etc assign OPR.)
&sin doesn't have OPR by default -- after (PUTPROP '&SIN '$SIN 'OPR)
I find "sin"(1) => 0.84147.
(2) The proposed change to CASIFY-EXPLODEN makes "sin" act
like $SIN instead of %SIN. That's OK by me although it might be
surprising because sin(1) => sin(1) (i.e. operator is a noun) unless
the user goes to some trouble to cause it to evaluate numerically.
There was some discussion recently on the mailing list about the
"verb implies numerical evaluation" policy.
best
Robert