Introduction
An .rkt file holds source code in
Racket, a language descended from
Scheme. It was called PLT Scheme until it was renamed in
2010. Racket is widely used for teaching and for building other languages, and its main
implementation runs on Chez Scheme.
Compiled code is cached in compiled/ folders as .zo files.
The .rktl extension is used for files loaded directly rather than as
modules, and .rktd for plain data.
Structure
A Racket file is UTF-8 text. Each file is one module, and the first line is usually a
#lang line naming the language the rest of the file is written in. That
may be racket, the smaller racket/base,
typed/racket or a language with another syntax entirely, such as
scribble/manual for documentation.
In the Racket languages the body is parenthesised forms. Square brackets may be used
in place of parentheses, and by habit they mark clauses such as the bindings in a
let. require brings in other modules, provide
exports names and a main submodule holds code that runs only when the file
is run directly. Comments use ;, #| … |# and
#;.
#lang racket/base
(provide greet)
; Returns a greeting; the main submodule prints one.
(define (greet name)
(string-append "Hello, " name))
(module+ main
(displayln (greet "world")))
Links
Software
Reference
- The Racket Guide – an introduction to the language
- The Racket Reference – the full description of the language and core libraries