add and use racket/repl

As suggested by Sam: Using `racket/repl` to start a read-eval-print
loop can mean that less code is loaded if a startup language other
than `racket/base` is selected.

Closes #2064
This commit is contained in:
Matthew Flatt 2018-05-30 15:54:57 +08:00
parent 388345f35f
commit 865efb7dda
6 changed files with 31 additions and 9 deletions

View File

@ -0,0 +1,12 @@
#lang scribble/doc
@(require "mz.rkt")
@title[#:tag "repl-module"]{The @racketmodname[racket/repl] Library}
@defmodule[racket/repl]
The @racketmodname[racket/repl] provides the same
@racket[read-eval-print-loop] binding as @racketmodname[racket/base], but
with even fewer internal dependencies than @racketmodname[racket/base]. It is
loaded in some situations on startup, as described in
@secref["init-actions"].

View File

@ -18,4 +18,5 @@
@include-section["code-inspectors.scrbl"] @include-section["code-inspectors.scrbl"]
@include-section["plumbers.scrbl"] @include-section["plumbers.scrbl"]
@include-section["sandbox.scrbl"] @include-section["sandbox.scrbl"]
@include-section["repl.scrbl"]
@include-section["linklet.scrbl"] @include-section["linklet.scrbl"]

View File

@ -80,20 +80,26 @@ submodule of the required module or the
language is used before the module is instantiated; see language is used before the module is instantiated; see
@secref["configure-runtime"]. @secref["configure-runtime"].
After running all command-line expressions, files, and modules, After running all command-line expressions, files, and modules, Racket
Racket or GRacket then starts a read-eval-print loop for interactive or GRacket then starts a read-eval-print loop for interactive
evaluation if no command line flags are provided other than evaluation if no command line flags are provided other than
@tech{configuration options}. If any command-line argument is @tech{configuration options}. For Racket, the read-eval-print loop is
run by calling @racket[read-eval-print-loop] from
@racketmodname[racket/repl]. For GRacket, the read-eval-print loop is
run by calling @racket[graphical-read-eval-print-loop] from
@racketmodname[racket/gui/base]. If any command-line argument is
provided that is not a @tech{configuration option}, then the provided that is not a @tech{configuration option}, then the
read-eval-print-loop is not started, unless the @Flag{i}/@DFlag{repl} read-eval-print-loop is not started, unless the @Flag{i}/@DFlag{repl}
flag is provided on the command line to flag is provided on the command line to
specifically re-enable it. In addition, just before the command line specifically re-enable it.
In addition, just before the read-eval-print loop
is started, Racket runs @racketmodname[racket/interactive] is started, Racket runs @racketmodname[racket/interactive]
and GRacket runs @racketmodname[racket/gui/interactive], unless a different and GRacket runs @racketmodname[racket/gui/interactive], unless a different
interactive file is specified in the the installation's @filepath{config.rktd} interactive file is specified in the the installation's @filepath{config.rktd}
file found in @racket[(find-config-dir)], or the file @filepath{interactive.rkt} file found in @racket[(find-config-dir)], or the file @filepath{interactive.rkt}
is found in @racket[(find-system-path 'addon-dir)]. If the is found in @racket[(find-system-path 'addon-dir)]. If the
@Flag{q}/@DFlag{no-init-file} flag is specified on the command line @Flag{q}/@DFlag{no-init-file} flag is specified on the command line,
then no interactive file is run. then no interactive file is run.
Finally, before Racket or GRacket exits, it calls the procedure that Finally, before Racket or GRacket exits, it calls the procedure that
@ -103,7 +109,10 @@ specified. Requiring @racketmodname[racket/gui/base] sets this parameter call
@racket[(racket 'yield)]. @racket[(racket 'yield)].
@history[#:changed "6.7" @elem{Run @racketmodname[racket/interactive] file @history[#:changed "6.7" @elem{Run @racketmodname[racket/interactive] file
rather than directly running @racket[(find-system-path 'init-file)].}] rather than directly running @racket[(find-system-path 'init-file)].}
#:changed "6.90.0.30" @elem{Run a read-eval-print loop by
using @racketmodname[racket/repl] or @racketmodname[racket/gui/base]
instead of @racketmodname[racket/base] or @racketmodname[racket/gui/init].}]
@; ---------------------------------------------------------------------- @; ----------------------------------------------------------------------

View File

@ -5,7 +5,7 @@
(module misc '#%kernel (module misc '#%kernel
(#%require "small-scheme.rkt" "define.rkt" "path.rkt" "old-path.rkt" (#%require "small-scheme.rkt" "define.rkt" "path.rkt" "old-path.rkt"
"path-list.rkt" "executable-path.rkt" "path-list.rkt" "executable-path.rkt"
"reading-param.rkt" "repl.rkt" "reading-param.rkt" "../repl.rkt"
(for-syntax '#%kernel "qq-and-or.rkt" "stx.rkt" "stxcase-scheme.rkt" "stxcase.rkt")) (for-syntax '#%kernel "qq-and-or.rkt" "stx.rkt" "stxcase-scheme.rkt" "stxcase.rkt"))
;; ------------------------------------------------------------------------- ;; -------------------------------------------------------------------------

View File

@ -482,13 +482,13 @@ static void do_scheme_rep(Scheme_Env *env, FinishArgs *fa)
#ifdef GRAPHICAL_REPL #ifdef GRAPHICAL_REPL
if (!fa->a->alternate_rep) { if (!fa->a->alternate_rep) {
a[0] = scheme_intern_symbol("racket/gui/init"); a[0] = scheme_intern_symbol("racket/gui/base");
a[1] = scheme_intern_symbol("graphical-read-eval-print-loop"); a[1] = scheme_intern_symbol("graphical-read-eval-print-loop");
ending_newline = 0; ending_newline = 0;
} else } else
#endif #endif
{ {
a[0] = scheme_intern_symbol("racket/base"); a[0] = scheme_intern_symbol("racket/repl");
a[1] = scheme_intern_symbol("read-eval-print-loop"); a[1] = scheme_intern_symbol("read-eval-print-loop");
} }