Documents
Each picture on this site is made of a small set of glyphs. This page gives the first four. Each later page adds one or two glyphs, and it uses all of the glyphs before it. Thus a large picture is made of the same parts as a small picture.
The glyphs so far: 4, 4 new on this page
- 42Data: a value without a typenew
- numberA document: the tab is its typenew42
- numberA dashed tab: the container declares the typenew42
- addParts: a card inside a cardnewnumber1number2
Data is a JSON value: a number, a text, a truth value, a list or a record. Data has no type of its own. Its glyph is the value alone.
A document is a value in an envelope
Section titled “A document is a value in an envelope”A document puts a value in an envelope: { "type": "number", "value": 42 }. The envelope names the type, and it does not change the value. The card is the envelope. Its tab is the type, and its body is the value.
The envelope can also hold a header: a name for a binding, and own entries that change one document. The later pages use both.
Why an envelope
Section titled “Why an envelope”A value can get a type in four common ways. Select a value to compare them.
| Way | JSON | Tags any value | Keeps the value | Room for a header | Type without a guess |
|---|---|---|---|---|---|
| A reserved key in the value | {"type":"alert","text":"low disk"} | yesA record can hold the key. | noThe value has its own field type. The tag overwrites it. | noA name or an own entry needs one more reserved key. | yesThe key gives the type. |
| An envelope: { type, value } | {"type":"alert","value":{"type":"warning","text":"low disk"}} | yesThe value can be any JSON value. | yesThe value is never changed. | yesA name and own entries go beside type. | yesThe envelope gives the type. |
| The type as the only key | {"alert":{"type":"warning","text":"low disk"}} | yesThe value can be any JSON value. | yesThe value is not changed. | noThe record has one key only. A name has no place. | yesThe key gives the type. |
| No tag: the shape decides | {"type":"warning","text":"low disk"} | noThere is no tag. | yesThe value is not changed. | noThere is no header. | noA guess from the fields gives the type. Two shapes can match. |
The envelope, drawn as a card
A container can declare the type
Section titled “A container can declare the type”A list of numbers does not need an envelope for each number. The kind of the list declares the type of its items. Such a value is bare, and its card has a dashed tab.
The first two numbers are bare. The list of add gives them the type number. The third number has its own envelope. Typed languages work in the same way: a declaration gives a type, and only an open position needs a tag.
One record can be in three lists, with three declared types. Each list gives the record a different meaning.
The same record, in three lists
| List | Kind | Evaluator | Result |
|---|---|---|---|
| photos | image | image.view | |
| frames | box | box.view | |
| upload rules | limit | limit.view |
A document can hold other documents. They are its parts, and their cards are inside its card. The kind of a document tells where its parts are. The next page shows the kinds.