REPL stands for read–evaluate-print loop. It’s pronounced repple. Racket’s REPL is an interactive prompt where you can type Racket expressions and see the results. The REPL is a quick way to run small evaluations.
The REPL is available two ways:
In your terminal window, by launching racket:
1 2 3 4 5 6 7 8 9
~ : racket Welcome to Racket v22.214.171.124. -> (* 6 7) 42 -> (current-milliseconds) -> 1510265906279 -> (define xyzzy (random 100)) -> xyzzy 83
You can specify a different language for this repl with the -I flag:
1 2 3 4 5
~ : racket -I br Welcome to Racket v126.96.36.199. -> (define-macro (foo THIS) #'42) -> (foo "you") 42
You can also access the REPL in DrRacket, by using the prompt in the interactions panel:
1 2 3 4 5
Welcome to DrRacket, version 188.8.131.52 [3m]. Language: racket [custom]; memory limit: 3000 MB. > (* 6 7) 42 >
Unlike the command-line REPL, the DrRacket REPL adopts the language specified by the #lang line at the top of the definitions panel. DrRacket also uses the REPL itself to print output from the program.
The DrRacket REPL lets you use variables and functions from the source file in the definitions window (even if they’re not made available through provide). So if this is the program:
After you run the file (to update the definitions), you can use them at the DrRacket REPL:
1 2 3 4 5 6 7
Welcome to DrRacket, version 184.108.40.206 [3m]. Language: br [custom]; memory limit: 3000 MB. > foo "bar" > (repeat foo) "barbar" >
Custom languages can activate the REPL by providing #%top-interaction from the expander. br/quicklang handles this for you, so languages made with br/quicklang automatically have REPL support.
More intricate REPL hacking is possible. For instance, the REPL can be configured to use a custom reader (other than Racket’s default S-expression reader).