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
140x0Emacros
150x0Fmodule
160x10export
170x11import
180x12flex_symbol
190x13flex_int
200x14flex_uint
210x15uint8
220x16uint16
230x17uint32
240x18uint64
250x19int8
260x1Aint16
270x1Bint32
280x1Cint64
290x1Dfloat16
300x1Efloat32
310x1Ffloat64
320x20zero-length text (i.e. '')
330x21for
340x22literal
350x23if_none
360x24if_some
370x25if_single
380x26if_multi
390x27none
400x28values
410x29default
420x2Ameta
430x2Brepeat
440x2Cflatten
450x2Ddelta
460x2Esum
470x2Fannotate
480x30make_string
490x31make_symbol
500x32make_decimal
510x33make_timestamp
520x34make_blob
530x35make_list
540x36make_sexp
550x37make_field
560x38make_struct
570x39parse_ion
580x3Aset_symbols
590x3Badd_symbols
600x3Cset_macros
610x3Dadd_macros
620x3Euse

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.^