2. Introduction

This language reference manual will not cover the basics of programming, instead it’s a reference manual for the language.

If you want to test out the language there is a REPL available.

2.1. Variables

Variables may store values from expression (e.g. constants or function calls) or callable function objects such as anonymous functions and named function pointers. In HSL variables are prefixed with $ followed by [a-zA-Z_]+[a-zA-Z0-9_]*. Variable names are case-sensitive. Some variables are read-only, hence they are not allowed to be assigned to (primarily pre-defined variables in contexts). Variables are assigned by value (copy-on-write).

$var = "foo";
$bar = $var;
$bar = "";
// $var is still "foo"


Variables in HSL are main/function scoped. However a variable needs to be created in all code paths before being used. isset() may test if a variable exists.

2.2. Functions

A lot of builtin functions are available in the function library. Functions are called by name followed by parentheses () with input parameters in between them. Function names are case-sensitive. The argument types must be supported by the function, otherwise an error will be raised. It’s also possible to create user-defined functions.

echo uptime();
echo length("Hello");


Calling a function with too few or too many arguments will raise an error, either during compilation time or at runtime (using argument unpacking).


Comments may be added to the code using two syntaxes, C-style “multi-line” comments and C++ “single-line” comments.

   multi-line comment

// single-line comment