Many Maxima functions give poor error messages when called with the wrong number of arguments, e.g.:
factor(2,3,4);
Maxima encountered a Lisp error:
invalid number of arguments: 3
Same thing for integerp, oddp, featurep, etc. etc.
This is ridiculous. A user calling a public Maxima function with the wrong number of arguments should get a nice clean error, identifying the function being called with the wrong number of argumens.
It should not be necessary to go into Lisp debugging mode to figure that out. Surely the exception includes information about what function is being called?!
Maxima version: "5.41.0a_dirty"
Maxima build date: "2017-10-24 09:10:17"
Host type: "x86_64-w64-mingw32"
Lisp implementation type: "SBCL"
Lisp implementation version: "1.3.18"
I agree, but I'm not really sure how to maek this happen except to change $factor to be bascially.
```
If that's what we need to do, that seems OK with me.
But I would have thought that the error handler could take care of it (but
I don't know how compatible the error handlers are in our different Lisps).
In any case, we have lots of ancient code where the functions are
unnecessarily argument-quoting (defmspec, old FEXPRs) -- and so have to
explicitly call meval -- because there was no other way to handle a
variable number of arguments.
On Mon, Aug 6, 2018 at 6:53 PM Raymond Toy rtoy@users.sourceforge.net
wrote:
Related
Bugs:
#3455For sbcl there seems to be a way, see: https://www.snellman.net/blog/archive/2007-12-19-pretty-sbcl-backtraces.html
For more lisps: https://github.com/gwkkwg/trivial-backtrace/blob/master/dev/backtrace.lisp
Common lisp offers a zillion of useful things that often are quite astonishing. The information which function has thrown an error it doesn't offer, though. So we have to use specific extensions of sbcl, clisp, ecl etc. In order to determine the command that threw an lisp error.
There is already some support for this in defun-checked (in clmacs.lisp), used in the quadpack routines (and maybe others). Doing this will slow everything down at least a little.
So
produces this nice error:
This would need to be extended to handle optional args like that used in $factor.
Dunno about DEFUN functions, but it seems like we could beef up the DEFMFUN macro to give a clearer error message for the wrong number of arguments.
I think this is appropriately handled by recent work on the DEFMFUN macro. At present (5.44.0) for the example cited I get:
I think that's a useful result.