From 1f01d0e200060f2874baf05178d4eea410397eb6 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 19 May 2018 22:21:07 -0700 Subject: [PATCH] READ no longer uses its environment arg, so remove it. --- doc/ref-manual/io.texi | 24 ++++--------------- src/edwin/artdebug.scm | 4 ++-- src/edwin/debug.scm | 14 ++++++----- src/edwin/evlcom.scm | 29 ++++++++++------------- src/edwin/intmod.scm | 10 +++----- src/edwin/prompt.scm | 3 +-- src/runtime/command-line.scm | 3 +-- src/runtime/dbgutl.scm | 3 +-- src/runtime/debug.scm | 3 +-- src/runtime/emacs.scm | 8 +++---- src/runtime/input-port.scm | 6 ++--- src/runtime/load.scm | 2 +- src/runtime/rep.scm | 19 +++++++-------- src/runtime/usrint.scm | 46 +++++++++++++----------------------- src/runtime/where.scm | 10 +++----- 15 files changed, 68 insertions(+), 116 deletions(-) diff --git a/doc/ref-manual/io.texi b/doc/ref-manual/io.texi index 7dfdab840..1adca4a87 100644 --- a/doc/ref-manual/io.texi +++ b/doc/ref-manual/io.texi @@ -566,7 +566,7 @@ ordinary file or a character string. In this section, all optional arguments called @var{port} default to the current input port. -@deffn {standard procedure} read [port [environment]] +@deffn {standard procedure} read [port] @cindex expression, input from port @cindex external representation, parsing @cindex parsing, of external representation @@ -592,11 +592,6 @@ return an end-of-file object. If an end of file is encountered after the beginning of an object's written representation, but the written representation is incomplete and therefore not parsable, an error is signalled. - -The optional argument @var{environment} is an MIT/GNU Scheme extension -that is used to look up the values of control variables such as -@code{param:reader-radix} (@pxref{reader-controls}). If not supplied, -it defaults to the @acronym{REP} environment. @end deffn @deffn {standard procedure} read-char [port] @@ -841,12 +836,7 @@ following equivalent code using @code{peek-char} and @code{read-char}: @subsection Reader Controls The following parameters control the behavior of the @code{read} -procedure. They are looked up in the environment that is passed to -@code{read}, and so may have different values in different -environments. The global parameters may be dynamically bound by -@code{parameterize}, but should not be mutated. Make persistent, -local changes by shadowing the global bindings in the local -environment and assigning new parameters to them. +procedure. @deffn parameter param:reader-radix This parameter defines the radix used by the reader when it parses @@ -1580,7 +1570,7 @@ given, this port defaults to the value of @code{(interaction-i/o-port)}; this is initially the console @acronym{I/O} port. -@deffn procedure prompt-for-command-expression prompt [port [environment]] +@deffn procedure prompt-for-command-expression prompt [port] Prompts the user for an expression that is to be executed as a command. This is the procedure called by the @acronym{REP} loop to read the user's expressions. @@ -1592,9 +1582,6 @@ prepending to the string the current @acronym{REP} loop ``level number'' and a space. Also, a space is appended to the string, unless it already ends in a space or is an empty string. -If @var{environment} is given, it is passed as the second argument to -@code{read}. - The default behavior of this procedure is to print a fresh line, a newline, and the prompt string; flush the output buffer; then read an object and return it. @@ -1636,16 +1623,13 @@ as input. After this mode change, the first such character submitted is returned as the value of this procedure. @end deffn -@deffn procedure prompt-for-expression prompt [port [environment]] +@deffn procedure prompt-for-expression prompt [port] Prompts the user for an expression. The prompt string is formed by appending a colon and a space to @var{prompt}, unless @var{prompt} already ends in a space or is the null string. -If @var{environment} is given, it is passed as the second argument to -@code{read}. - The default behavior of this procedure is to print a fresh line, a newline, and the prompt string; flush the output buffer; then read an object and return it. diff --git a/src/edwin/artdebug.scm b/src/edwin/artdebug.scm index 1ecc3af5d..98f8e0fa8 100644 --- a/src/edwin/artdebug.scm +++ b/src/edwin/artdebug.scm @@ -1338,8 +1338,8 @@ Prefix argument means do not kill the debugger buffer." (newline port) (newline port)) -(define (operation/prompt-for-expression port environment prompt) - port environment +(define (operation/prompt-for-expression port prompt) + port (prompt-for-expression prompt)) (define (operation/prompt-for-confirmation port prompt) diff --git a/src/edwin/debug.scm b/src/edwin/debug.scm index 84d7a0b32..22f4df511 100644 --- a/src/edwin/debug.scm +++ b/src/edwin/debug.scm @@ -478,16 +478,18 @@ USA. (define interface-port-type (make-port-type - `((WRITE-CHAR + `((write-char ,(lambda (port char) (guarantee 8-bit-char? char) (region-insert-char! (port/state port) char) 1)) - (PROMPT-FOR-CONFIRMATION - ,(lambda (port prompt) port (prompt-for-confirmation? prompt))) - (PROMPT-FOR-EXPRESSION - ,(lambda (port environment prompt) - port environment + (prompt-for-confirmation + ,(lambda (port prompt) + (declare (ignore port)) + (prompt-for-confirmation? prompt))) + (prompt-for-expression + ,(lambda (port prompt) + (declare (ignore port)) (prompt-for-expression prompt)))) #f)) diff --git a/src/edwin/evlcom.scm b/src/edwin/evlcom.scm index 969b2ca9b..058640296 100644 --- a/src/edwin/evlcom.scm +++ b/src/edwin/evlcom.scm @@ -316,13 +316,12 @@ Has no effect if evaluate-in-inferior-repl is false." ;; This sets up the correct environment in the typein buffer ;; so that completion of variables works right. (local-set-variable! scheme-environment environment buffer)) - options) - environment))) + options)))) -(define (read-from-string string environment) +(define (read-from-string string) (bind-condition-handler (list condition-type:error) evaluation-error-handler (lambda () - (read (open-input-string string) environment)))) + (read (open-input-string string))))) (define-major-mode prompt-for-expression scheme #f (mode-description (ref-mode-object minibuffer-local)) @@ -355,25 +354,21 @@ Has no effect if evaluate-in-inferior-repl is false." evaluation-error-handler (lambda () (let loop - ((expressions (read-expressions-from-region region environment)) + ((expressions (read-expressions-from-region region)) (result unspecific)) (if (null? expressions) result (loop (cdr expressions) (editor-eval buffer (car expressions) environment)))))))) -(define (read-expressions-from-region region #!optional environment) - (let ((environment - (if (default-object? environment) - (evaluation-environment region) - environment))) - (call-with-input-region region - (lambda (port) - (let loop () - (let ((expression (read port environment))) - (if (eof-object? expression) - '() - (cons expression (loop))))))))) +(define (read-expressions-from-region region) + (call-with-input-region region + (lambda (port) + (let loop () + (let ((expression (read port))) + (if (eof-object? expression) + '() + (cons expression (loop)))))))) (define (evaluation-environment #!optional buffer global-ok?) (let ((buffer (->buffer buffer))) diff --git a/src/edwin/intmod.scm b/src/edwin/intmod.scm index 600e8f6f4..d1fd9c6d9 100644 --- a/src/edwin/intmod.scm +++ b/src/edwin/intmod.scm @@ -1051,11 +1051,8 @@ If this is an error, the debugger examines the error condition." ;;; Prompting -(define (operation/prompt-for-expression port environment prompt) - (unsolicited-prompt port - (lambda (prompt) - (prompt-for-expression prompt #!default environment)) - prompt)) +(define (operation/prompt-for-expression port prompt) + (unsolicited-prompt port prompt-for-expression prompt)) (define (operation/prompt-for-confirmation port prompt) (unsolicited-prompt port prompt-for-confirmation? prompt)) @@ -1119,8 +1116,7 @@ If this is an error, the debugger examines the error condition." (remove-select-buffer-hook buffer hook)))))) (add-select-buffer-hook buffer hook)))) -(define (operation/prompt-for-command-expression port environment prompt level) - environment +(define (operation/prompt-for-command-expression port prompt level) (parse-command-prompt port prompt) (read-expression port level)) diff --git a/src/edwin/prompt.scm b/src/edwin/prompt.scm index 85a59e7a1..f3746692f 100644 --- a/src/edwin/prompt.scm +++ b/src/edwin/prompt.scm @@ -989,8 +989,7 @@ it is added to the front of the command history." (prompt-for-string "Redo" #f 'DEFAULT-TYPE 'INSERTED-DEFAULT 'HISTORY 'REPEAT-COMPLEX-COMMAND - 'HISTORY-INDEX (- argument 1)) - (->environment '(EDWIN)))))) + 'HISTORY-INDEX (- argument 1)))))) ;;;; Pass-phrase Prompts diff --git a/src/runtime/command-line.scm b/src/runtime/command-line.scm index b34bd559c..2c7cece6b 100644 --- a/src/runtime/command-line.scm +++ b/src/runtime/command-line.scm @@ -270,8 +270,7 @@ ADDITIONAL OPTIONS supported by this band:\n") (run-in-nearest-repl (lambda (repl) (let ((environment (repl/environment repl))) - (repl-eval/write (read (open-input-string arg) - environment) + (repl-eval/write (read (open-input-string arg)) environment repl))))) "Evaluates the argument expressions as if in the REPL.") diff --git a/src/runtime/dbgutl.scm b/src/runtime/dbgutl.scm index 2edadb2ba..5e34077c8 100644 --- a/src/runtime/dbgutl.scm +++ b/src/runtime/dbgutl.scm @@ -69,8 +69,7 @@ USA. (define (debug/read-eval-print-1 environment port) (let ((value - (debug/eval (prompt-for-expression "Evaluate expression" - port environment) + (debug/eval (prompt-for-expression "Evaluate expression" port) environment))) (if (undefined-value? value) (debugger-message port "No value") diff --git a/src/runtime/debug.scm b/src/runtime/debug.scm index 928568f48..d85fa1ef9 100644 --- a/src/runtime/debug.scm +++ b/src/runtime/debug.scm @@ -771,8 +771,7 @@ USA. (if invalid-expression? "" " ($ to retry)")) - port - environment))) + port))) (if (and (not invalid-expression?) (eq? expression '$)) (debug/scode-eval (dstate/expression dstate) diff --git a/src/runtime/emacs.scm b/src/runtime/emacs.scm index 6964c8c6c..734c616f5 100644 --- a/src/runtime/emacs.scm +++ b/src/runtime/emacs.scm @@ -31,10 +31,10 @@ USA. ;;;; Prompting -(define (emacs/prompt-for-command-expression port environment prompt level) +(define (emacs/prompt-for-command-expression port prompt level) (transmit-modeline-string port prompt level) (transmit-signal port #\R) - (read port environment)) + (read port)) (define (emacs/prompt-for-command-char port prompt level) (transmit-modeline-string port prompt level) @@ -60,9 +60,9 @@ USA. '(("debug> " "[Debug]") ("where> " "[Where]"))) -(define (emacs/prompt-for-expression port environment prompt) +(define (emacs/prompt-for-expression port prompt) (transmit-signal-with-argument port #\i prompt) - (read port environment)) + (read port)) (define (emacs/prompt-for-confirmation port prompt) (transmit-signal-with-argument diff --git a/src/runtime/input-port.scm b/src/runtime/input-port.scm index 97d332cbf..443a533d8 100644 --- a/src/runtime/input-port.scm +++ b/src/runtime/input-port.scm @@ -179,12 +179,10 @@ USA. (else (eof-object))))) ""))) -(define (read #!optional port environment) - (declare (ignore environment)) +(define (read #!optional port) (read-top-level (optional-input-port port 'read))) -(define (read-file pathname #!optional environment) - (declare (ignore environment)) +(define (read-file pathname) (call-with-input-file (pathname-default-version pathname 'newest) (lambda (port) (let loop ((sexps '())) diff --git a/src/runtime/load.scm b/src/runtime/load.scm index f3bd08708..7a72c6ad6 100644 --- a/src/runtime/load.scm +++ b/src/runtime/load.scm @@ -124,7 +124,7 @@ USA. (call-with-input-file pathname (lambda (port) (let loop ((value unspecific)) - (let ((sexp (read port environment))) + (let ((sexp (read port))) (if (eof-object? sexp) value (loop (repl-eval sexp environment))))))))) diff --git a/src/runtime/rep.scm b/src/runtime/rep.scm index 9b862ecb8..ac35bdb64 100644 --- a/src/runtime/rep.scm +++ b/src/runtime/rep.scm @@ -442,7 +442,7 @@ USA. (do () (#f) (if (queue-empty? queue) (let ((environment (repl/environment repl))) - (%repl-eval/write (hook/repl-read environment repl) + (%repl-eval/write (hook/repl-read repl) environment repl)) ((dequeue! queue) repl))))) @@ -451,15 +451,16 @@ USA. (guarantee unary-procedure? procedure 'run-in-nearest-repl) (enqueue! (repl/input-queue (nearest-repl)) procedure)) -(define (repl-read #!optional environment repl) - (receive (environment repl) (optional-er environment repl 'repl-read) - (hook/repl-read environment repl))) +(define (repl-read #!optional repl) + (hook/repl-read + (if (default-object? repl) + (nearest-repl) + (guarantee repl? repl 'repl-read)))) (define hook/repl-read) -(define (default/repl-read environment repl) +(define (default/repl-read repl) (prompt-for-command-expression (cons 'standard (repl/prompt repl)) - (cmdl/port repl) - environment)) + (cmdl/port repl))) (define (repl-eval s-expression #!optional environment repl) (receive (environment repl) (optional-er environment repl 'repl-eval) @@ -527,9 +528,7 @@ USA. (let ((repl (if (default-object? repl) (nearest-repl) - (begin - (guarantee repl? repl caller) - repl)))) + (guarantee repl? repl caller)))) (values (if (default-object? environment) (repl/environment repl) (guarantee environment? environment caller)) diff --git a/src/runtime/usrint.scm b/src/runtime/usrint.scm index adb8fe152..1acc4b94c 100644 --- a/src/runtime/usrint.scm +++ b/src/runtime/usrint.scm @@ -31,46 +31,37 @@ USA. ;;;; Prompting -(define (prompt-for-command-expression prompt #!optional port environment) +(define (prompt-for-command-expression prompt #!optional port) (let ((prompt (canonicalize-command-prompt prompt)) (port (optional-port port 'prompt-for-command-expression)) - (environment - (optional-environment environment 'prompt-for-command-expression)) (level (nearest-cmdl/level))) (let ((operation (textual-port-operation port 'prompt-for-command-expression))) (if operation - (operation port environment prompt level) + (operation port prompt level) (begin (guarantee textual-i/o-port? port 'prompt-for-command-expression) (write-command-prompt port prompt level) (with-input-port-terminal-mode port 'cooked (lambda () - (read port environment)))))))) + (read port)))))))) -(define (prompt-for-expression prompt #!optional port environment) - (%prompt-for-expression - (optional-port port 'prompt-for-expression) - (optional-environment environment 'prompt-for-expression) - prompt - 'prompt-for-expression)) +(define (prompt-for-expression prompt #!optional port) + (%prompt-for-expression port prompt 'prompt-for-expression)) (define (prompt-for-evaluated-expression prompt #!optional environment port) - (let ((environment - (optional-environment environment 'prompt-for-evaluated-expression)) - (port (optional-port port 'prompt-for-evaluated-expression))) - (repl-eval - (%prompt-for-expression port - environment - prompt - 'prompt-for-evaluated-expression) - environment))) - -(define (%prompt-for-expression port environment prompt caller) - (let ((prompt (canonicalize-prompt prompt ": "))) + (repl-eval + (%prompt-for-expression port prompt 'prompt-for-evaluated-expression) + (if (default-object? environment) + (nearest-repl/environment) + (guarantee environment? environment 'prompt-for-evaluated-expression)))) + +(define (%prompt-for-expression port prompt caller) + (let ((port (optional-port port caller)) + (prompt (canonicalize-prompt prompt ": "))) (let ((operation (textual-port-operation port 'prompt-for-expression))) (if operation - (operation port environment prompt) + (operation port prompt) (begin (guarantee textual-i/o-port? port caller) (with-output-port-terminal-mode port 'cooked @@ -81,17 +72,12 @@ USA. (flush-output-port port))) (with-input-port-terminal-mode port 'cooked (lambda () - (read port environment)))))))) + (read port)))))))) (define (optional-port port caller) (if (default-object? port) (interaction-i/o-port) (guarantee textual-port? port caller))) - -(define (optional-environment environment caller) - (if (default-object? environment) - (nearest-repl/environment) - (guarantee environment? environment caller))) (define (prompt-for-command-char prompt #!optional port) (let ((prompt (canonicalize-command-prompt prompt)) diff --git a/src/runtime/where.scm b/src/runtime/where.scm index be3f48cb9..8df05495f 100644 --- a/src/runtime/where.scm +++ b/src/runtime/where.scm @@ -122,13 +122,9 @@ USA. (show-environment-procedure (car (wstate/frame-list wstate)) port)) (define (recursive-where wstate port) - (let ((environment (car (wstate/frame-list wstate)))) - (let ((inp - (prompt-for-expression "Object to evaluate and examine" - port - environment))) - (debugger-message port "New where!") - (debug/where (debug/eval inp environment))))) + (let ((inp (prompt-for-expression "Object to evaluate and examine" port))) + (debugger-message port "New where!") + (debug/where (debug/eval inp (car (wstate/frame-list wstate)))))) (define (enter wstate port) port -- 2.25.1