<a id="introduction"></a>

# 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](https://docs.halon.io/manual/cli.html#script-interpreter) available.

<a id="variables"></a>

## 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](http://en.wikipedia.org/wiki/Copy-on-write)).

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

> **Note**
> 
> Variables in HSL are main/function scoped. However a variable needs to be created in all code paths before being used. [`isset()`](functions.html.md#isset) may test if a variable exists.

<a id="functions"></a>

## Functions

A lot of builtin functions are available in the [function library](functions.html.md). 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](structures.html.md#user-function).

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

> **Warning**
> 
> Calling a function with too few or too many arguments will raise an error, either during compilation time or at runtime (using [argument unpacking](structures.html.md#argumentunpacking)).

<a id="comment"></a>

<a id="comments"></a>

## Comments

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

```hsl
/*
   multi-line comment
*/

// single-line comment
```
