{"path":"/sutl/guide/quoting-and-evaluation","content":{"title":"4. Quoting and evaluation","summary":"Literal values, recursive quotation and evaluating constructed transforms.","body":"[sUTL](/sutl) · [Guide](/sutl/guide) · [Reference](/sutl/reference) · [Examples](/sutl/examples)\n\nBecause code and data share the same representation, sUTL needs explicit ways\nto delay evaluation and to evaluate constructed transforms.\n\n## Literal values with `:`\n\nThe colon form returns its value without traversing it:\n\n```json\n{\":\": \"^$.name\"}\n```\n\nThis returns the string `\"^$.name\"` rather than following the path.\n\n## Recursive quotation with `'`\n\nThe quote form walks a structure while suppressing ordinary evaluation.\nDouble quote `''` escapes back into evaluation:\n\n```json\n{\n  \"'\": {\n    \"literal\": \"^$.value\",\n    \"evaluated\": {\"''\": \"^$.value\"}\n  }\n}\n```\n\nWith `{\"value\": 42}`, the result is:\n\n```json\n{\n  \"literal\": \"^$.value\",\n  \"evaluated\": 42\n}\n```\n\n## Evaluating a constructed transform with `!`\n\n`!` evaluates its value to obtain another transform, adds the remaining map\nmembers to scope, and evaluates that transform:\n\n```json\n{\n  \"!\": {\"'\": [\"&+\", \"^@.x\", \"^@.y\"]},\n  \"y\": 3\n}\n```\n\nWith `{\"x\": 2}`, this returns `5`.\n\n## The explicit `!!` form\n\nThe later Studio dialect separates the next transform from its scope delta:\n\n```json\n{\n  \"!!\": {\":\": {\"answer\": \"^@.value\"}},\n  \"s\": {\"value\": 7}\n}\n```\n\nResult:\n\n```json\n{\"answer\": 7}\n```\n\nPrefer this form for new higher-order code: it is clearer about what becomes\nscope. The production Python 2 port omitted it, while Studio/HaxeJS contained a\nscope-merge bug; the original site and handwritten JavaScript establish the\nintended behavior.\n\n## Why quote appears around callbacks\n\nDictionary members are evaluated before a builtin receives its scope. A\ncallback passed to `if` or `reduce` must normally be quoted once so the builtin\ncan evaluate it later in the correct scope.\n\nNext: [Scope and reduction](/sutl/guide/scope-and-reduce).\n\n## Continue learning\n\n[Previous: 3. Builtins](/sutl/guide/builtins) · [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/04-quoting-and-evaluation.md).\n\n[Back to sUTL](/sutl) · [Software & Agents](/topics/software-and-agents) · [All topics](/guide)","author":"Emlyn O'Regan"}}