-
-
Notifications
You must be signed in to change notification settings - Fork 4
data
Angle usually uses the wasp data format:
person{name="Joe"}
person{name:"Joe" number:12345 address:{street=…}}
Everything is a node internally.
Nodes have internal primitive types:
{} objects, [] patterns and () groups
Denoted by different braces: {} [] ()
In data, without evaluation these groupings are similar:
{1 2 3} [1 2 3] (1 2 3)
all denote a list with 3 elements.
{a:1 b:2 c:3} [a:1 b:2 c:3] (a:1 b:2 c:3)
all denote a map with 3 elements.
However upon evaluation, compilation and interpretation they can have different semantics.
{}
is the most ambitious of those three groupings:
block, code and closure denoted by {}
are very similar concepts:
- every data with the intention of being evaluated is a block
- every block with concrete binding is code
- every code with a local-only binding is a closure
There is a subtle difference between
person{name:"Joe" address{street:"no way 123"}}
person:{name="Joe" address:{street="no way 123"}}
While both construct an object person
, the variant with colon constructs pure data while the variant without colon constructs the person via a constructor, if available.
So if previously type person is defined like
a person has a random id
then Joe will automatically derive that id if constructed as person{name:"Joe"}.
The pure data built with person:{name="Joe"} only has a soft-type of person, an elusive unenforced type hint.
Apart from the above canonical format, Angle can also consume lisp/mark/polish-notation style data:
(person (name Joe))
Since these formats have different semantics, the lisp style needs a special keyword to activate the slightly modified parser.
Another slightly different format treats each line as a node instead of list:
html lang="en" {
head {
meta charset="utf-8"
meta name="viewport" content="width=device-width, initial-scale=1.0"
meta \
name="description" \
content="kdl is a document language, mostly based on SDLang, with xml-like semantics that looks like you're invoking a bunch of CLI commands!"
title "kdl - Kat's Document Language"
link rel="stylesheet" href="/styles/global.css"
}```
https://github.com/kdl-org/kdl/blob/main/examples/website.kdl#L27