6. Declarations and libraries
Named transforms, dependency resolution, acceptance tests and builtin overrides.
sUTL · Guide · Reference · Examples
evaluate operates on transforms. A declaration gives a transform a name,
dependencies, language tag, and optional acceptance test:
{
"name": "addone_example_org",
"language": "sUTL",
"transform-t": ["&+", "^@.value", 1],
"requires": []
}
A distribution is an ordered list of declarations.
Requiring a transform
Requirements use prefix matching. Requiring "addone" can select
"addone_example_org". compilelib stores the selected transform under the
required name, so callers use:
{
"!": "^*.addone",
"value": 4
}
* selects the compiled library; the result is 5.
Transitive requirements
If a selected declaration has requirements of its own, compilelib resolves
those recursively. The sUTL 1.0 implementation reports a missing requirement as a
compile failure instead of creating an incomplete library.
Acceptance tests
A declaration's optional test-t is evaluated with transform-t as its
source. Falsey means success; truthy conventionally contains failure messages.
This allowed consumers to accept a compatible declaration without relying on a
central version number.
Naming
Historical names progress from specific to general and commonly end in a domain namespace:
map_core_emlynoregan_com
A consumer may require map, map_core, or the full name. Shorter prefixes
allow substitution but can also match unintended candidates, so applications
should choose requirements deliberately.
Library overrides
Library transforms named _override_<builtin> replace host builtins. The Python 2 implementation contains a string-formatting defect
in this path. The sUTL runner implements the intended spelling, but new
guide examples do not depend on overrides.
Next: Larger transformations.
Continue learning
Previous: 5. Scope and reduction · Guide contents · Language reference
Source
Adapted from the sUTL source material.