Slang scripts are a great way to easily play around with Slang language features.

Slang scripts are files that contain a collection of Slang declarations along with executable Slang statements. They’re based on the Scala script file concept (and its Ammonite variant), and use the same file extension .sc. The main benefit of using a Slang script is that one can quickly write and execute some Slang, as opposed putting in the effort to set up a full mill or Sbt based Slang project. Since it aims for simplicity, the Slang script mechanism provides a “single file” execution concept – although a script file can import libraries, a script file cannot reference definitions in other script files. Scripts are executed using a “script runner” provided by the Sireum infrastructure – the script runner automatically sets up a build (compiling the script and Scala source files in the source path) and executes the script. Currently, the IVE debugger cannot be used for Slang scripts. Therefore, if one needs a multi-file code organization or IVE debugging support, a full Slang project must be used instead of a script.

There are two common styles of use for Slang scripts:

  • (Basic) A lightweight mechanism for experimenting with Slang concepts, working with small examples when teaching with Slang, etc. without setting a full project supported by a build framework. Even though Slang scripts cannot call each other, a single IVE project can be used to hold multiple related scripts.

  • (Advanced) Using Slang to write cross-platform “shell scripts” – Slash, that can be used in place of, e.g., sh shell scripts or Windows batch files. The Sireum infrastructure uses this style of Slang scripts to achieve portability of Sireum installation, updates, and other OS/shell related actions across macOS, Linux, and Windows platforms.

This chapter describes set up and execution of scripts for “basic” use. A similar description of “advanced” use is provided in XXX. The instructions/description assumes that Sireum has been installed and that the reader is comfortable with invoking Sireum from the command line. After initial set up, working with Slang scripts is supported in the Sireum IVE. The instructions below first address working with scripts in the Sireum IVE and then describe how to scripts can be executed from the command line.