Pragmas Section
Attention: This section is included for completeness only, and is unlikely to prove valuable except to 1) those who wish to bootstrap an Avail system ex nihilo or 2) the incurably curious who wish to bone up on Avail trivia for some reason. It is recommended that most readers skip this section. If you are reading the Module series in order, then you should skip ahead to Module Packages.
The Pragmas
keyword begins the pragmas section. The contents of this section are zero or more string literals separated by commas ,
(U+002C)
. Each string literal encodes a pragma; the enclosing quotation marks "
(U+0022)
are not part of the syntax of a pragma. A pragma[1] is a special directive to the system. There are three distinct kinds of pragma:
check
- A
check
pragma asserts that some quality of the Avail virtual machine is compatible with the module. Acheck
pragma comprises thecheck
keyword, then an equals sign=
(U+003D)
, then a property, then an equals sign, then a value:property
is the property, andvalue
is the property value. The format and character of the value is determined by the property. The supported properties are:version
- The property value is a comma-separated list of acceptable virtual machine versions. This is analogous to the required versions list of an import specification; it is not identical in form, however, because the versions of the property value are not enclosed in quotation marks (and thus cannot contain commas). The Avail virtual machine maintains an internal list of supported virtual machine versions, analogous to the active versions section of a module. When the pragma is processed, if there are no versions in common between these two lists, then an error message is displayed and the virtual machine halts.
method
- A
method
pragma introduces a new atom and associates it with the primitive function designated by the specified primitive number. Amethod
pragma comprises themethod
keyword, then an equals sign, then a primitive number, then an equals sign, then a canonical message.primitiveNumber
is the primitive number andmessage
is the message. The arity of the message must agree with the arity of the primitive function. If a send of the message fails for any reason, then the primitive fails as if by sending"Crash:_"
to a 2-tuple whose first element is the failure code and whose second element is a tuple of the primitive function's arguments. stringify
- A
stringify
pragma tells the Avail virtual machine what message it should send in order to stringify an arbitrary value. Whenever the compiler or executor is called upon to render a textual description of a value — for example, when the compiler emits an error message — this message is sent to the value. Astringify
pragma comprises thestringify
keyword, then an equals sign, then a canonical message:message
is the stringification message. The stringification message must have an arity of 1. If stringification fails for any reason, then the system falls back on the internal mechanism used by"primitive descriptive of_"
to render a textual description of the value, prepending a parenthetical indication that the attempt to stringfy failed.
At the time of writing, the only module that contains a pragmas section is Origin
, the indirect submodule of Avail
that serves as the root of the entire system. It is presented here in the fullness of its majesty:
The bootstrapping of primitive functions 240 (special object access) and 253 (method definition) via method
pragmas is the absolute minimum requirement for interfacing with the Avail virtual machine.
[1] The term "pragma" is an abbreviation of "pragmatic".
‹ Extended Imports Section | | | Return to Modules | | | Module Packages › |