Subject: What are the magic performed by (cl-user::run)?
From: Robert Dodier
Date: Mon, 30 Apr 2012 15:21:08 +0000 (UTC)
On 2012-04-27, Rupert Swarbrick <rswarbrick at gmail.com> wrote:
> To the rest of the list: Should there be an
> init-maxima-and-make-it-work-please function that RUN calls? Then people
> that want to embed maxima into another CL image wouldn't have to guess
> about what's needed. Yes, I know you can load your code into a maxima
> image, but if you don't want a maxima REPL, that doesn't really help
> (since RUN brings one up).
I;ve separated the initialization stuff from the read-eval-print loop
in CL-USER:RUN and moved that stuff into a new function,
INITIALIZE-RUNTIME-GLOBALS. I expect this will be useful to programs
which want to replace the read-eval-print loop. CL-USER:RUN has the same
effect as before; it calls the new function and then starts its loop.
I've pushed this change; for the record there is a diff below.
best,
Robert Dodier
PS.
diff --git a/src/init-cl.lisp b/src/init-cl.lisp
index c0f17f4..78527ad 100644
--- a/src/init-cl.lisp
+++ b/src/init-cl.lisp
@@ -546,6 +546,17 @@ When one changes, the other does too."
(defun cl-user::run ()
"Run Maxima in its own package."
(in-package :maxima)
+ (initialize-runtime-globals)
+ (let ((input-stream *standard-input*)
+ (batch-flag nil))
+ (catch 'to-lisp
+ (setf (values input-stream batch-flag)
+ (process-maxima-args input-stream batch-flag))
+ (loop
+ (with-simple-restart (macsyma-quit "Maxima top-level")
+ (macsyma-top-level input-stream batch-flag))))))
+
+(defun initialize-runtime-globals ()
(setf *load-verbose* nil)
(setf *debugger-hook* #'maxima-lisp-debugger)
;; See discussion on the maxima list
@@ -568,30 +579,23 @@ When one changes, the other does too."
;; variable. Hence we need to set it here to get our desired
;; behavior.
(setf *read-default-float-format* 'double-float))
- (let ((input-stream *standard-input*)
- (batch-flag nil))
- #+allegro
- (progn
- (set-readtable-for-macsyma)
- (setf *read-default-float-format* 'lisp::double-float))
- (catch 'to-lisp
- (initialize-real-and-run-time)
- (intl::setlocale)
- (set-locale-subdir)
- (adjust-character-encoding)
- (set-pathnames)
- (when (boundp '*maxima-prefix*)
- (push (pathname (concatenate 'string *maxima-prefix*
- (if *maxima-layout-autotools*
- "/share/locale/"
- "/locale/")))
- intl::*locale-directories*))
- (setf (values input-stream batch-flag)
- (process-maxima-args input-stream batch-flag))
- (loop
- (with-simple-restart (macsyma-quit "Maxima top-level")
- (macsyma-top-level input-stream batch-flag))))))
+ #+allegro
+ (progn
+ (set-readtable-for-macsyma)
+ (setf *read-default-float-format* 'lisp::double-float))
+
+ (initialize-real-and-run-time)
+ (intl::setlocale)
+ (set-locale-subdir)
+ (adjust-character-encoding)
+ (set-pathnames)
+ (when (boundp '*maxima-prefix*)
+ (push (pathname (concatenate 'string *maxima-prefix*
+ (if *maxima-layout-autotools*
+ "/share/locale/"
+ "/locale/")))
+ intl::*locale-directories*)))
(defun adjust-character-encoding ()
(ignore-errors