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 v188.8.131.52. -> (* 6 7) 42 -> (current-milliseconds) -> 1679754861744 -> (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 v184.108.40.206. -> (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 220.127.116.11 [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 18.104.22.168 [3m]. Language: br [custom]; memory limit: 3000 MB. > foo "bar" > (repeat foo) "barbar" >
Textual output is just the beginning of the DrRacket REPL. It can display a range of data formats, including images and interactive plots.
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).
Other command-line options for racket in the Racket Reference
The interactions window in the DrRacket docs