compile(script, @key assemble, exe, ld_options, cc_options, output, exception_handler)

Compile the Slogan source code script file into the intermediate language or machine code.

The code in intermediate language is suitable for interpretation by the Slogan interpreter while machine code can be executed directly on hardware.

If exe is true, script is compiled to produce a standalone executable.

If assemble is true, a dynamically loadable file of machine instructions is generated from script.

If provided, cc_options must be a string that specifies additional command-line options for the C compiler, which is used internally by Slogan for generating machine code.

If provided, ld_options must be a string that specifies additional command-line options for the linker.

The name of the generated file may be customized using output.

If provided, exception_handler must be a function that takes a single argument. If compilation raises an exception, this function will be called with the error object as the argument.

Return true on success.


showln("hello, world")

The above script can be compiled into intermediate language representation by the call,


The resulting .scm file can be loaded and interpreted by the Slogan interpreter.

The script can be translated into a dynamically loadable machine code module by,

compile("hello", assemble = true)

The resulting machine code (or object code) file can be linked into a Slogan program, including the interpreter (the REPL).

If the target machine do not have the Slogan interpreter or runtime installed, you can generate a standalone executable that will run directly on hardware:

compile("hello", exe = true)

Also see:


Core Module Index | Contents