From: rtoy <rt...@us...> - 2024-09-30 13:36:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Maxima CAS". The branch, master has been updated via 842eb746a3add7b53b23bbc21af287ab981193a8 (commit) from cab32dcb1e108d14f3c7988f7662e12bc337b255 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 842eb746a3add7b53b23bbc21af287ab981193a8 Author: Raymond Toy <toy...@gm...> Date: Mon Sep 30 06:32:27 2024 -0700 Use :setting-predicate to assert the vars takes strings In commit [cab32dcb1e], the variables `$newline`, `$tab`, and `$space` were updated to assert that only strings could be assigned to them. This is a slight change to use the `:setting-predicate` option to `defmvar` instead of manually setting the `assign` property for these variables. I think this is easier to read and maintain. Manually tested this to verify that we throw an error when setting `$space` to a number. Also verified that a string works as expected. diff --git a/share/stringproc/stringproc.lisp b/share/stringproc/stringproc.lisp index 19f1ef704..42f0028cf 100644 --- a/share/stringproc/stringproc.lisp +++ b/share/stringproc/stringproc.lisp @@ -726,20 +726,23 @@ Please use `unicode' for code points larger than 127." ))) ;; Special Maxima characters ;; -(defmvar $newline - (string #\newline) "Maxima newline character") - -(setf (get '$newline 'assign) (lambda (x y) (when (not (stringp y)) (mseterr x y "must be a string")))) - -(defmvar $tab - (string #\tab) "Maxima tab character") - -(setf (get '$tab 'assign) (lambda (x y) (when (not (stringp y)) (mseterr x y "must be a string")))) - -(defmvar $space - (string #\space) "Maxima space character") - -(setf (get '$space 'assign) (lambda (x y) (when (not (stringp y)) (mseterr x y "must be a string")))) +(defmvar $newline (string #\newline) + "Maxima newline character" + :setting-predicate #'(lambda (x) + (values (stringp x) + "must be a string"))) + +(defmvar $tab (string #\tab) + "Maxima tab character" + :setting-predicate #'(lambda (x) + (values (stringp x) + "must be a string"))) + +(defmvar $space (string #\space) + "Maxima space character" + :setting-predicate #'(lambda (x) + (values (stringp x) + "must be a string"))) (defun $tab () $tab) ;; returns Maxima tab character; can be autoloaded ----------------------------------------------------------------------- Summary of changes: share/stringproc/stringproc.lisp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) hooks/post-receive -- Maxima CAS |