mset error messages



Hi, Leo, I think it's a great idea to improve the error messages from mset.

However, I'd recommend that they be phrased in terms that make sense to the
end user, not the implementor.

For example, as far as I know, the 'neverset' flag is not settable or
readable by the user, nor mentioned in user documentation. Also, the
neverset flag covers several cases which are different from the user's point
of view:

all -- A system constant (why isn't this SYSCONST T?)
values, functions, ... -- System-maintained list -- to remove items from
these lists, use KILL
error -- Not user-assignable: Always contains the last error message given
by Maxima

etc.

          -s



On Mon, Mar 29, 2010 at 04:47, Leo Butler <l.butler at ed.ac.uk> wrote:

> Hi,
> I'd like to improve the error messages from mset, to clarify
> why an attempted assignment fails.
>
> Here is my proposed patch, which I think is consistent with the recent work
> to provide messages that are wrapped in gettext.
>
> I've run the test suite with the patched code, and no additional
> errors are reported.
>
> Ex:
> (%i2) all:1;
>
> assignment: cannot assign to all; it has the `neverset'
> property.
>  -- an error. To debug this try: debugmode(true);
> (%i3) %e:2.71;
>
> assignment: cannot assign to %e; it is a declared numeric quantity.
>  -- an error. To debug this try: debugmode(true);
>
> Leo
>
>
> Index: src/mlisp.lisp
> ===================================================================
> RCS file: /cvsroot/maxima/maxima/src/mlisp.lisp,v
> retrieving revision 1.85
> diff -u -r1.85 mlisp.lisp
> --- src/mlisp.lisp      21 Mar 2010 07:06:54 -0000      1.85
> +++ src/mlisp.lisp      29 Mar 2010 08:24:44 -0000
> @@ -618,6 +618,9 @@
>   (twoargcheck l)
>   (mset (simplifya (cadr l) nil) (meval (caddr l))))
>
> +(defvar *mset-error-message* ""
> +  "Last error message caused by invoking mset (:)")
> +
>  (defun mset (x y)
>   (prog ()
>      (cond ((or (null $setcheck)
> @@ -633,14 +636,16 @@
>                  (merrbreak t)
>                  (setq y $setval)))))
>      (cond ((atom x)
> -           (when (or (not (symbolp x))
> -                     (member x '(t nil) :test #'eq)
> -                      (mget x '$numer)
> -                      (get x 'sysconst))
> +           (when (or (and (not (symbolp x))
> +                          (setf *mset-error-message* (intl:gettext "it
> is not a symbolp.")))
> +                     (and (member x '(t nil) :test #'eq)
> +                          (setf *mset-error-message* (intl:gettext
> "true and false are Maxima constants.")))
> +                      (and (mget x '$numer)
> +                          (setf *mset-error-message* (intl:gettext "it
> is a declared numeric quantity.")))
> +                      (and (get x 'sysconst)
> +                          (setf *mset-error-message* (intl:gettext "it
> is a Maxima constant."))))
>              (if munbindp (return nil))
> -             (if (mget x '$numer)
> -                 (merror (intl:gettext "assignment: cannot assign to
>                  ~M; it is a declared numeric quantity.") x)
> -                 (merror (intl:gettext "assignment: cannot assign to
>                  ~M") x)))
> +             (merror (intl:gettext "assignment: cannot assign to ~M;
> ~a") x *mset-error-message*))
>            (let ((f (get x 'assign)))
>              (if (and f (or (not (eq x y))
>                             (member f '(neverset read-only-assign) :test
> #'eq)))
>
>  (defmfun neverset (x assign-val)
>   (declare (ignore assign-val))
>   (if munbindp
>       'munbindp
> -      (merror (intl:gettext "assignment: cannot assign to ~:M") x)))
> +      (merror (intl:gettext "assignment: cannot assign to ~:M; it has
> the `neverset' property.") x)))
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>