$sqrt vs %sqrt



On Fri, Oct 3, 2008 at 2:54 PM, Reinhard Oldenburg
<oldenbur at math.uni-frankfurt.de> wrote:

> Maybe the problem comes from the following behaviour which I don't
> understand:
> When I am (in-package "MAXIMA") and do (parse-string "sqrt(x)")  then I
> get  ((%SQRT) $X).
> However, when I do  (maxima::parse-string "sqrt(x)") from my package I
> get  (($SQRT) $X).
> So what is the difference between $sqrt and %sqrt?

Reinhard, Maxima implements a system of so-called nouns and verbs
in which nouns represent formal expressions and verbs represent
function calls. Internally verbs have symbols which begin w/ $
and nouns have %.

Externally an expression 'foo(x) is parsed into a noun expression
((%FOO) $X). However some functions such as sin, cos, sqrt, etc.,
are parsed directly into ((%SIN) ...) etc without the ' .

The parser looks at symbol properties to decide whether it should
output the noun. However those properties are attached to symbols
in the :maxima package so when you are in a different package,
the parser fails to see the properties and it doesn't carry out the
automatic nounification.

Probably the parser should intern symbols in the :maxima package.
Here's a 1-line change to effect that (from src/commac.lisp):

(defun intern-invert-case (string)
  ;; Like read-from-string with readtable-case :invert
  ;; Supply package argument in case this function is called
  ;; from outside the :maxima package.
  (intern (maybe-invert-string-case string) :maxima))

On the whole it seems more useful to intern symbols in :maxima.
I'll commit this change unless someone convinces me otherwise.

best

Robert Dodier