Janet Notes and Examples

Executables and Running Janet

Todo:

  • args to pass to janet
  • main function
  • dofile

Load a module on the command line

You can start the repl and then import the module:

$ janet
repl> (import ./foo)
repl> (foo/bar 5)

You could also load the module with a command line arg:

$ janet -l ./foo
repl> (bar 5)  # Calling `foo/bar` here.

which allows you to access the foo module’s public bindings without the “foo/” prefix.

Note, janet -r foo.janet executes foo.janet, but doesn’t load it into the repl environment.

Build a Standalone Executable

TODO. You can also compile your Janet programs into standalone executables. todo Janet interpreter baked-in to a C program. This can be useful to make distribution of your program more convenient.