10 Using Racket Tools and Libraries
The DrRacket programming environment supports Rhombus, and (as noted in Building and Running Rhombus Programs) Racket tools more generally work on Rhombus programs. Racket tools work because Rhombus is built on Racket’s #lang mechanism.
The rhombus executable is a fairly thin wrapper around racket. The rhombus command-line accepts module paths using Rhombus syntax instead of Racket syntax, and it starts an interactive Rhombus session if no starting module is provided. Also, rhombus checks and caches compiled versions of modules by default, whereas racket checks and caches only when the -y flag is used.
Racket provides many libraries and packages that (at the time of
writing) have not yet been ported or wrapped for convenient use in
Rhombus. A Racket module can be imported into a Rhombus
module, and because Racket and Rhombus share many of the same data
representations—
Here are some key techniques for using Racket libraries in Rhombus:
To import a collection-based Racket module, use lib and make the ".rkt" file extension or "main.rkt" file name explicit. For example, lib("racket/base.rkt") imports from racket/base, while lib("racket/main.rkt") imports from racket.
Use #{…} to refer to Racket identifiers that do not fit the syntax of Rhombus identifiers. For example, #{path-string?} is the Racket predicate that corresponds to the Rhombus PathString annotation. Similarly, #{#:replace-permissions?} is a keyword argument for the Racket function #{open-output-file}.
Racket lists are PairLists, not Lists. Racket strings are mutable by default, so use to_string to convert a Racket string result to a Rhombus-friendly string.
Racket syntactic forms cannot be used from Rhombus, but a Rhombus macro can expand to a use of a Racket syntactic form via expr_meta.pack_s_exp and similar.
For more information, see the Rhombus and Racket Interoperability documentation.