17.3.4 Installing a Language

So far, we have used the reader meta-language to access languages like "literal.rkt" and "dollar-racket.rkt". If you want to use something like #lang literal directly, then you must move "literal.rkt" into a Racket collection named "literal".

To install a collection, you can create a directory either in the main Racket installation or in a user-specific directory. Use find-collects-dir or find-user-collects-dir from setup/dirs to find the directory:

> (require setup/dirs)
> (find-user-collects-dir)

#<path:/home/racketeer/.racket/5.1.1/collects>

Move "literal.rkt" to "literal/lang/reader.rkt" within the directory reported by find-collects-dir or find-user-collects-dir. That is, the file "literal.rkt" must be renamed to "reader.rkt" and placed in a "lang" sub-directory of the "literal" collection.

.... (the main installation or the user’s space)
 |- "collects"
      |- "literal"
           |- "lang"
                |- "reader.rkt"

After moving the file, you can use literal directly after #lang:

#lang literal
Technology!
System!
Perfect!

See raco: Racket Command-Line Tools for more information on using raco.

You can also package a collection for others to install by using the raco pack command-line tool:

  raco pack --collection literal.plt literal

Then, others can install the "literal" collection using raco setup:

  raco setup literal.plt

See PLaneT: Automatic Package Distribution for more information about PLaneT packages.

A better approach may be to distribute your language as a PLaneT package. A drawback of using a PLaneT package is that users must type #lang planet followed by a PLaneT path to access the language. The great advantages are that the PLaneT package can be installed automatically, it can be versioned, and it co-exists more easily with other packages.