-
-
Notifications
You must be signed in to change notification settings - Fork 4
key
In Wasp, a key is a node with another node as its value.
a:1
b:"Hello"
c:fibonacci
d:fibonacci(10)
e: x+1
person:{name:James, age:45}
The person example shows how key value pairs form natural nested data: maps and trees.
The difference to person{name:James, age:45}
is, that here person contains name:James and age:45 as children.
In person:{name:James, age:45}
person contains {name:James, age:45} as value.
{name:James, age:45}
itself is an unnamed object with children name:James and age:45.
Internally these slightly different representations may be normed and flattened at times.
Semantically person:{name:James, age:45}
is passive data whereas person{name:James, age:45}
denotes an active constructor of person if available, otherwise passive data too.
In Wasp, keys need not be primitive values, but can be complex objects:
(a b c):(d e f)
This is represented internally by having the left side as children and the right side as value
The value of a key can never be null, but it can unknown: Either as a reference to a node of type unknown, or by pointing to null. Such keys can still have a type.
Unlike other languages, a key in Wasp contains it's value itself.
In Wasp, a key is a node of internal kind Type::key.