11

.rkt is the conventional file extension for 'regular' Racket source code. In the documentation, I also see .rktl and .rkts being used. What are .rktl and .rkts used for, and are there any more Racket filename extensions I am not aware of?

Flux
  • 9,805
  • 5
  • 46
  • 92

1 Answers1

12

The .rkt file extension is generally used for files that represent modules. These normally have a #lang .... line at the top, or sometimes (module ....). They can be imported as modules with require.

The .rktl and .rkts file extensions are used for files meant to be loaded at the top-level that aren't modules. They don't necessarily have a #lang .... line at the top, and must be loaded in some external environment with load instead of imported with require. These usually have a more "dynamic" feel to them, and they're used more often with scripts that use mutation of variables across multiple files. This is not the "encouraged" style in Racket.

The .rktd file extension is used for files that just have data encoded as s-expressions, not code. These files should not be required or loaded (they should not be executed as code). However, other programs use them to store data on the file system using write, and to read the data later using read. Its purpose is the same as a .sexp file or a .json file, just pure data.

Alex Knauth
  • 8,133
  • 2
  • 16
  • 31
  • So `.rktl` and `.rkts` are interchangeable? – Flux Oct 22 '18 at 13:22
  • I'm not sure. I've seen `.rktl` used for load-scripts, but I've actually never seen `.rkts` used in actual code before. – Alex Knauth Oct 22 '18 at 13:56
  • I don't see any `.rkts` files in the racket source directory. So it wouldn't surprise me if its an old extension, or if someone else uses it to generate Racket code, or if you are thinking of something like `rktc`, which is racket pre-processed c code. – Leif Andersen Oct 22 '18 at 17:03
  • @LeifAndersen `.rkts` is used in the [documentation](https://docs.racket-lang.org/guide/load.html). – Flux Oct 22 '18 at 23:34