{"path":"/sutl/guide/declarations-and-libraries","content":{"title":"6. Declarations and libraries","summary":"Named transforms, dependency resolution, acceptance tests and builtin overrides.","body":"[sUTL](/sutl) · [Guide](/sutl/guide) · [Reference](/sutl/reference) · [Examples](/sutl/examples)\n\n`evaluate` operates on transforms. A **declaration** gives a transform a name,\ndependencies, language tag, and optional acceptance test:\n\n```json\n{\n  \"name\": \"addone_example_org\",\n  \"language\": \"sUTL\",\n  \"transform-t\": [\"&+\", \"^@.value\", 1],\n  \"requires\": []\n}\n```\n\nA distribution is an ordered list of declarations.\n\n## Requiring a transform\n\nRequirements use prefix matching. Requiring `\"addone\"` can select\n`\"addone_example_org\"`. `compilelib` stores the selected transform under the\nrequired name, so callers use:\n\n```json\n{\n  \"!\": \"^*.addone\",\n  \"value\": 4\n}\n```\n\n`*` selects the compiled library; the result is `5`.\n\n## Transitive requirements\n\nIf a selected declaration has requirements of its own, `compilelib` resolves\nthose recursively. The sUTL 1.0 implementation reports a missing requirement as a\ncompile failure instead of creating an incomplete library.\n\n## Acceptance tests\n\nA declaration's optional `test-t` is evaluated with `transform-t` as its\nsource. Falsey means success; truthy conventionally contains failure messages.\nThis allowed consumers to accept a compatible declaration without relying on a\ncentral version number.\n\n## Naming\n\nHistorical names progress from specific to general and commonly end in a\ndomain namespace:\n\n```text\nmap_core_emlynoregan_com\n```\n\nA consumer may require `map`, `map_core`, or the full name. Shorter prefixes\nallow substitution but can also match unintended candidates, so applications\nshould choose requirements deliberately.\n\n## Library overrides\n\nLibrary transforms named `_override_<builtin>` replace host builtins. The Python 2 implementation contains a string-formatting defect\nin this path. The sUTL runner implements the intended spelling, but new\nguide examples do not depend on overrides.\n\nNext: [Larger transformations](/sutl/guide/larger-transformations).\n\n## Continue learning\n\n[Previous: 5. Scope and reduction](/sutl/guide/scope-and-reduce) · [Guide contents](/sutl/guide) · [Language reference](/sutl/reference)\n\n## Source\n\nAdapted from [the sUTL source material](https://github.com/emlynoregan/sutllang-site/blob/e59ecafd364848cd71a1d18ce74cdf67f2f69328/content/guide/06-declarations-and-libraries.md).\n\n[Back to sUTL](/sutl) · [Software & Agents](/topics/software-and-agents) · [All topics](/guide)","author":"Emlyn O'Regan"}}