More elegant Halon scripting with lambda abstraction

At the center of the Halon SMTP platform is our domain-specific scripting language. As our users are well aware, the syntax is inspired by languages such as PHP (e.g. $variable) and Python (e.g. slices [0:10]). Although the implementation differs vastly, the concept of having a purpose-tailored scripting language as a form of configuration exists in other projects as well, such as Varnish.

In our pursuit of even more readable and elegant solutions, we’ve extended the scripting language to support various aspects of lambda abstraction; namely

Making functions first-class citizens makes a lot of sense, given that most of our customers already uses callbacks functions for things like external API calls’ cache behaviour.

Although HSL is arguably very similar to PHP, keep in mind that they are different languages with different syntax. Unlike PHP, all array_ functions takes the callback function as the first argument.

$strings = array_filter(is_string, $array);
$double = array_map(function ($x) { return $x*2; }, $array);

You’ll likely see more of anonymous functions in the future; this is just the beginning!