rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

Lisp error for 'at(a, b) #4089

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-09 11:19:24 Created by robert_dodier on 2023-12-26 00:34:59 Original: https://sourceforge.net/p/maxima/bugs/4226


'at(a, b) provokes a Lisp error: "CAR: $B is not a list"

at(a, b) provokes a Maxima error: "at: improper argument: b"

I guess at is expecting the second argument to be an equation or a list of equations. That's great, so the Maxima error from at(a, b) is okay; the problem is that 'at(a, b) should likewise give a Maxima error, not a Lisp error.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-09 11:19:25 Created by peterpall on 2023-12-26 07:40:45 Original: https://sourceforge.net/p/maxima/bugs/4226/#d2fc


while "improper argument" is correct we might be more specific here, too...

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-09 11:19:29 Created by tomio-arisaka on 2023-12-28 13:17:04 Original: https://sourceforge.net/p/maxima/bugs/4226/#e035


The function $AT is here: (an extract from "src/comm2.lisp")

(defmfun $at (expr ateqs)
  (if (notloreq ateqs) (improper-arg-err ateqs '$at))
  (atscan (let ((*atp* t)) ($psubstitute ateqs expr)) ateqs))

(if (notloreq ateqs) (improper-arg-err ateqs '$at)) checks the second argument of $AT, and shows the error message if necessary.

On the other hand, the function SIMP-%AT does not have it as follows:

(defprop %at simp-%at operators)

(defun simp-%at (expr ignored simp-flag)
  (declare (ignore ignored))
  (twoargcheck expr)
  (let* ((arg (simpcheck (cadr expr) simp-flag))
         (e (resimplify (caddr expr)))
         (eqn (if ($listp e)
                  (if (= ($length e) 1) ($first e) (cons '(mlist simp) (cdr ($sort e))))
                  e)))
    (cond (($constantp arg) arg)
          ((alike1 eqn '((mlist))) arg)
          ((at-not-dependent eqn arg))
          (t (eqtest (list '(%at) arg eqn) expr)))))