Hyperlambda structure

This page is part of the magic.lambda documentation.

Hyperlambda is the textual representation of a node structure, where each node has a name, an optional value, and a collection of children nodes. Imagine the following Hyperlambda.

name:value
   child1

In the above Hyperlambda there is one root node. Its name is “name”, its value is “value”, and this node has one child node, with the name of “child1”. Its child node does not however have a value, which results in its value being “null”. The reason why the Hyperlambda parser understands “child1” as the child of the “name” node, is because it is prefixed by 3 spaces (SP) relative to the “name” node. This allows you to create graph objects (tree structures) with any depth you wish, by simply starting out with the number of spaces the node above has, add 3 additional spaces, and you have declared children nodes of the node above.

If you think of these nodes as a sequence of function invocations, from the top to bottom, where all of the nodes are assumed to be referencing slots, and all children nodes arguments to your slots - You can imagine how the tree structure resulting from parsing Hyperlambda into a graph object can easily be evaluated, due to its recursive nature, making it easy to express idioms such as “if”, “while”, “for-each”, etc. In fact logically this is similar to the way XSLT works, except there’s no XML, only Hyperlambda, lambda objects, and nodes.

Since each slot will be invoked with the node referencing the slot itself as the “input” Node, this makes the Hyperlambda evaluator recursive in nature, allowing a slot to evaluate all of its children, after executing its custom logic, etc. And yes, before you ask, Hyperlambda has been heavily influenced by LISP. In some ways Hyperlambda is Lisp for C#, only with a completely different syntax, and without S-Expressions.


← Hyperlambda internals all of magic.lambda Extending Hyperlambda with C# →