The system module

The symbols and macros of the system module $ion are available everywhere within an Ion document, with the version of that module being determined by the spec-version of each segment. The specific system symbols are largely uninteresting to users; while the binary encoding heavily leverages the system symbol table, the text encoding that users typically interact with does not. The system macros are more visible, especially to authors of macros.

This chapter catalogs the system-provided symbols and macros. The examples below use unqualified names, which works assuming no other macros with the same name are in scope. The unambiguous form $ion::macro-name is always available to use.

Relation to local symbol and macro tables

In Ion 1.0, the system symbol table is always the first import of the local symbol table. However, in Ion 1.1, the system symbol and macro tables have a system address space that is distinct from the local address space, but can optionally be included in the user address space.

When starting an Ion 1.1 segment (i.e. immediately after encountering an $ion_1_1 version marker), the system module is in the sequence of active encoding modules immediately following the default module. As a result, both the system macros and system symbols are initially included in the local macro and symbol tables1. The system module is not a permanent fixture in the active encoding modules, so (in contrast to Ion 1.0) the system symbols and macros can be removed from the local symbol and macro tables.

System Symbols

The Ion 1.1 System Symbol table replaces rather than extends the Ion 1.0 System Symbol table. The system symbols are as follows:

IDHexText
00x00<reserved>
10x01$ion
20x02$ion_1_0
30x03$ion_symbol_table
40x04name
50x05version
60x06imports
70x07symbols
80x08max_id
90x09$ion_shared_symbol_table
100x0Aencoding
110x0B$ion_literal
120x0C$ion_shared_module
130x0Dmacro
140x0Emacro_table
150x0Fsymbol_table
160x10module
170x11export
180x12import
190x13flex_symbol
200x14flex_int
210x15flex_uint
220x16uint8
230x17uint16
240x18uint32
250x19uint64
260x1Aint8
270x1Bint16
280x1Cint32
290x1Dint64
300x1Efloat16
310x1Ffloat32
320x20float64
330x21zero-length text (i.e. '')
340x22for
350x23literal
360x24if_none
370x25if_some
380x26if_single
390x27if_multi
400x28none
410x29values
420x2Adefault
430x2Bmeta
440x2Crepeat
450x2Dflatten
460x2Edelta
470x2Fsum
480x30annotate
490x31make_string
500x32make_symbol
510x33make_decimal
520x34make_timestamp
530x35make_blob
540x36make_list
550x37make_sexp
560x38make_field
570x39make_struct
580x3Aparse_ion
590x3Bset_symbols
600x3Cadd_symbols
610x3Dset_macros
620x3Eadd_macros
630x3Fuse

In Ion 1.1 Text, system symbols can never be referenced by symbol ID; $1 always refers to the first symbol in the user symbol table. This allows the Ion 1.1 system symbol table to be relatively large without taking away SID space from the user symbol table.

System Macros

IDHexText
00x00none
10x01values
20x02default
30x03meta
40x04repeat
50x05flatten
60x06delta
70x07sum
80x08annotate
90x09make_string
100x0Amake_symbol
110x0Bmake_decimal
120x0Cmake_timestamp
130x0Dmake_blob
140x0Emake_list
150x0Fmake_sexp
160x10make_field
170x11make_struct
180x12parse_ion
190x13set_symbols
200x14add_symbols
210x15set_macros
220x16add_macros
230x17use

1

System symbols require the same number of bytes whether they are encoded using the system symbol or the user symbol encoding. The reasons the system symbols are initially loaded into the user symbol table are twofold—to be consistent with loading the system macros into user space, and so that implementors can start testing user symbols even before they have implemented support for reading encoding directives.^