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 in the template definition language.

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. When starting an Ion 1.1 segment (i.e. immediately after encountering an $ion_1_1 version marker), the local symbol table is prepopulated with the system symbols1. The local macro table is also prepopulated with the system macros. However, the system symbols and macros are not permanent fixtures of the local symbol and macro tables respectively.

When a local macro has the same name as a system macro, it shadows the system macro. In TDL, it is still possible to invoke a shadowed system macro by using a qualified name, such as $ion::make_string. If a macro in the active local macro table has the same name as a system macro, it is impossible to invoke that system macro by name using an E-Expression. (It is still possible to invoke the system macro if the local macro table has assigned an alias for that system macro.)

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
100x0A$ion_encoding
110x0B$ion_literal
120x0C$ion_shared_module
130x0Dmacro
140x0Emacro_table
150x0Fsymbol_table
160x10module
170x11see ion-docs#345
180x12export
190x13see ion-docs#345
200x14import
210x15zero-length text (i.e. '')
220x16literal
230x17if_none
240x18if_some
250x19if_single
260x1Aif_multi
270x1Bfor
280x1Cdefault
290x1Dvalues
300x1Eannotate
310x1Fmake_string
320x20make_symbol
330x21make_blob
340x22make_decimal
350x23make_timestamp
360x24make_list
370x25make_sexp
380x26make_struct
390x27parse_ion
400x28repeat
410x29delta
420x2Aflatten
430x2Bsum
440x2Cset_symbols
450x2Dadd_symbols
460x2Eset_macros
470x2Fadd_macros
480x30use
490x31meta
500x32flex_symbol
510x33flex_int
520x34flex_uint
530x35uint8
540x36uint16
550x37uint32
560x38uint64
570x39int8
580x3Aint16
590x3Bint32
600x3Cint64
610x3Dfloat16
620x3Efloat32
630x3Ffloat64
640x40none
650x41make_field

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
20x02annotate
30x03make_string
40x04make_symbol
50x05make_blob
60x06make_decimal
70x07make_timestamp
80x08make_list
90x09make_sexp
100x0Amake_struct
110x0Bset_symbols
120x0Cadd_symbols
130x0Dset_macros
140x0Eadd_macros
150x0Fuse
160x10parse_ion
170x11repeat
180x12delta
190x13flatten
200x14sum
210x15meta
220x16make_field
230x17default

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