Suppose I have a file like
#lang racket/base
(define (hello) (print "Hello"))
... more definitions ...
and I would like to load the definitions in the file to interactively work with them in the (X)REPL. How do I do that?
If I start the (X)REPL and (load "/tmp/hello.rkt")
, then the hello
function is not made available to me:
-> (hello)
; hello: undefined;
If I (require (file "/tmp/hello.rkt"))
, the result is the same. Now I can (enter! (file "/tmp/hello.rkt"))
and then (hello)
works, but this seems rather ... unintuitive and beginner-unfriendly.
Is this indeed the way this should be done and should I simply read up on modules and namespaces to easily browse and experiment with my code or is there a simpler way I'm overlooking?
N.B. I found How do you load a file into racket via command line?, but that only explains how to run the file. Not how to load it in the REPL, so you can test/debug some specific definitions, then edit, reload, etc.