我使用的是Ubuntu 18.04操作系统,Racket版本为7.6。我创建了一个名为hello.rkt的文件:
#lang racket
(define (hello) 'hello-world)
(hello)
然后我调用它:
> racket hello.rkt
'hello-world
好的。接下来,我尝试将代码加载到REPL中并使用:
> 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; ...
简言之:我如何在toplevel命令行REPL上下文中加载文件并使用它们的内容?
简述如下:如何在toplevel命令行REPL上下文中加载文件并使用它们的内容?