---
title: Streamline Halon scripting with lambda abstraction
description: Discover how lambda abstraction simplifies Halon scripting, enabling more elegant and efficient email infrastructure management.
---

[News | Halon ](https://halon.io/blog)

# [Streamline Halon scripting with lambda abstraction](https://halon.io/blog/more-elegant-halon-scripting-with-lambda-abstraction)

 Written by [Anders Berggren](https://halon.io/blog/author/anders-berggren) | Dec 6, 2015 11:00:00 PM

[Photo](https://www.flickr.com/photos/drexler/2505123707) by [David Drexler](https://www.flickr.com/photos/drexler/)

At the center of the Halon SMTP platform is our domain-specific [scripting language](http://docs.halon.se/hsl/index.html). As our users are well aware, the syntax is inspired by languages such as [PHP](http://php.net) (e.g. $variable) and [Python](https://www.python.org) (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

- A function [data type](http://docs.halon.se/hsl/literals.html#function) 
    - [Anonymous](http://docs.halon.se/hsl/literals.html#anonymous-functions) [functions](http://docs.halon.se/hsl/structures.html#anonymous-functions)
    - [Named function pointers](http://docs.halon.se/hsl/literals.html#named-function-pointers)
    - A universal function [invokation operator](http://docs.halon.se/hsl/operators.html#function)
- Higher-order functions such as [array_map()](http://docs.halon.se/hsl/functions.html#array_map) and [array_reduce()](http://docs.halon.se/hsl/functions.html#array_reduce)
- Callback to functions such as [in_file()](http://docs.halon.se/hsl/functions.html#in_file), [in_array()](http://docs.halon.se/hsl/functions.html#in_array), [pcre_replace()](http://docs.halon.se/hsl/functions.html#pcre_replace), etc

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](http://docs.halon.se/hsl/structures.html#cache) behaviour.

Although HSL is arguably very similar to PHP, keep in mind that they are different languages with different syntax. [Unlike](http://php.net/manual/en/function.array-filter.php) [PHP](http://php.net/manual/en/function.array-map.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!

[View full post](https://halon.io/blog/more-elegant-halon-scripting-with-lambda-abstraction)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Anders Berggren"
  },
  "dateModified" : "2025-02-18T07:16:55.689Z",
  "datePublished" : "2015-12-06T23:00:00Z",
  "headline" : "More elegant Halon scripting with lambda abstraction",
  "image" : {
    "@type" : "ImageObject",
    "height" : 219,
    "url" : "https://2734201.fs1.hubspotusercontent-na1.net/hubfs/2734201/Imported_Blog_Media/lambda.jpg",
    "width" : 1000
  },
  "mainEntityOfPage" : "https://halon.io/blog/more-elegant-halon-scripting-with-lambda-abstraction",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Halon blog"
  }
}
```