From 594e34e1145e0b23a685e1685a181751dd5d0044 Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Sun, 28 Jun 2026 23:17:02 +0200 Subject: Yet another NaN-packing design change. --- doc/0/1-parse.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'doc/0/1-parse.md') diff --git a/doc/0/1-parse.md b/doc/0/1-parse.md index 54b1dd4..91407da 100644 --- a/doc/0/1-parse.md +++ b/doc/0/1-parse.md @@ -6,9 +6,9 @@ Zisp s-expressions represent an extremely minimal set of data types; only that which is necessary to strategically construct more complex values: +---------+--------+--------+ - | String | Rune | List | + | String | List | Rune | +---------+--------+--------+ - | foobar | #name | (...) | + | foobar | (...) | #name | +---------+--------+--------+ The parser recognizes various *syntax sugar* which abbreviates verbose syntax, @@ -199,6 +199,26 @@ contain NUL bytes, in which case this optimization isn't used.) Longer strings may be *interned* which is a feature explained further below. Otherwise, each string is allocated separately, and represented by its unique memory address. +### List + +A list is a sequence of values with a fixed length. + +A unique, contiguous array of values is allocated in program memory for each +list of non-zero length, and the list as a value is then represented by the +memory address of the array. The empty list is represented by a distinct +canonical bit pattern. + +Lists are valid as a datum if one of the following holds true: + +* The list encodes a quoted string, datum label, or shebang line. + +* All values in the list are a valid datum, or it is empty. + +Further, a structure of nested list values may not contain cyclic references +back up in the structure (which would make the above definition diverge into +infinity). Such cycles must be broken up with datum labels, or else the list +cannot be considered a datum, since it cannot be printed or parsed. + ### Rune A rune is represented by an ASCII character sequence of 1 to 6 bytes, that must @@ -219,26 +239,6 @@ default decoder settings and documented explicitly as such. Runes are always stored directly in a CPU word; never by memory address. -### List - -A list is a sequence of values with a fixed length. - -A unique, contiguous array of values is allocated in program memory for each -list of non-zero length, and the list as a value is then represented by the -memory address of the array. The empty list is represented by a specific -canonical bit pattern. - -Lists are valid as a datum if one of the following holds true: - -* The list encodes a quoted string, datum label, or shebang line. - -* All values in the list are a valid datum, or it is empty. - -Further, a structure of nested list values may not contain cyclic references -back up in the structure (which would make the above definition diverge into -infinity). Such cycles must be broken up with datum labels, or else the list -cannot be considered a datum, since it cannot be printed or parsed. - ## String interning -- cgit v1.2.3