An atom is a mutable value associated with a module-allocated name. For each name that appears in the
Names section of a module's header, the compiler associates that name with a new atom. For each name that appears in the
Extends section of a module's header, the compiler associates that name with the atom introduced by the module that named it. During compilation of a module, an atom may be retrieved by presenting its name, a string, to the primitive method
"atom for_". If the atom was neither introduced by the current module nor imported from another module, then
"atom for_" privately introduces a new atom into the current module; a subsequent send with the same argument within the context of the same module will produce the same atom.
In ordinary use, the primary asset of an atom is its distinction from every other value, including an equivalently named atom that originated in a different module. Consider the values
false from classical logic. The principal characteristic of each is its distinction from the other. In other words,
false differ by identity rather than by some measurable quantity. In Avail, the values
false are special atoms; they are issued by the virtual machine rather than some module. The type
boolean is simply the finite enumeration of these two atoms. For another example, consider a simple model of colors:
In addition to a name and an issuing module, an atom also comprises a collection of bindings, called properties. Since an atom has identity, it can acquire new properties, update existing properties, and lose properties altogether. A property is an association between another atom — the property key — and an arbitrary value — the property value. The properties of an atom are not enumerable, thus ensuring modular usage; an algorithm can only query or alter a property for which it possesses the key. A property is interrogated using the method
"_[_]" ([atom, atom]→⊤), added or updated via
"_[_]:=_" ([atom, atom, any]→⊤), and removed with
"Remove_[_]" ([atom, atom]→⊤). For each of these methods, the first atom is the target and the second atom is the property key.
The following example extends the previous one by associating wavelengths to the
rainbow color atoms:
atom has every atom as an instance.
atom is a complete type. Though its properties are analogous to the bindings of a map or the attributes of an object,
atom does not require (or permit) type parameters for the property key type or the property value type. These limitations are a direct consequence of mutability.
Note that special atoms cannot participate in the property mechanism. For instance, the special atom
true cannot be either the target or the property key of a property interrogation. It can be a property value, however.
|||||Return to Type System|||||