I'm on Ubuntu 18.04 using Racket 7.6. I created this file, hello.rkt:
#lang racket
(define (hello) 'hello-world)
(hello)
Then I invoked it:
> racket hello.rkt
'hello-world
Nice. Next I tried to load the code into the REPL and use it:
> racket -i hello.rkt
Welcome to Racket v7.6.
> (hello) ; the function is unavailable here
; hello: undefined;
; cannot reference an identifier before its definition
; in module: top-level
; [,bt for context]
> (load "hello.rkt") ; load gives no error, but ...
> (hello) ; the function is unavailable here
; hello: undefined; ...
> (require "hello.rkt") ; require gives no error ...
'hello-world ; and runs (hello), but ...
> (hello) ; the function is unavailable here
; hello: undefined; ...
> (include "hello.rkt") ; include gives no error, but ...
> (hello) ; the function is unavailable here
; hello: undefined; ...
> (enter! "hello.rkt") ; enter! gives no error, but ...
"hello.rkt"> (enter! "other.rkt") ; if I enter! another file ...
"other.rkt"> (hello) ; the hello function is unavailable here
; hello: undefined; ...
In brief: How do I load files and use their contents in the toplevel command-line REPL context?