The Racket Reference sections 11.9 Expanding Top-Level Forms and 13.2 Evaluation and Compilation use the term "top-level-form" and the descriptions of the functions (eval top-level-form [nm]) and (expand top-level-form) in the reference manual have "top-level-form" as their function argument, but I'm unclear about the definition of "top-level-form". What is the meaning of the term "top-level-form" within the Racket language?
The intuition here is that these functions all deal with "top-level forms" as opposed to a form that depends on a lexical environment. As a semi-obvious example, eval
can only deal with top-level forms, which is why this:
(let ([x 10])
(eval '(* 3 x)))
doesn't work. The usual use of just "forms" is talking about any forms, such as inputs to macros -- which of course can have such references.
I have now found the precise definition of top-level-form in a kind of Backus-Naur format in the Racket Reference manual section 1.2.3.1
http://docs.racket-lang.org/reference/syntax-model.html#(part._fully-expanded)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With