On this page

Scope contrast one tree๏ƒ

๐ŸŸข Beginner ยท Lesson 34

unique vs unique_per_conduit in the SAME conduit tree - the side-by-side that makes scope reach click.

Before you run๏ƒ

Use the Beginner guide for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules.

Run the saved script๏ƒ

python UX_and_AIX_experiences/01_beginner/34_scope_contrast_one_tree.py
py -3.14t UX_and_AIX_experiences/01_beginner/34_scope_contrast_one_tree.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

md.Existence.unique vs unique_per_conduit contrast

Code๏ƒ

 1"""
 2TIER: beginner (34)
 3GOAL: unique vs unique_per_conduit in the SAME conduit tree - the
 4      side-by-side that makes scope reach click.
 5SURFACE EXERCISED: md.Existence.unique vs unique_per_conduit contrast
 6"""
 7import melder as md
 8
 9
10class GlobalRegistry:
11    pass
12
13
14class ScopeCache:
15    pass
16
17
18def main() -> None:
19    book = md.Spellbook()
20    book.bind(spell=GlobalRegistry, existence="unique")
21    book.bind(spell=ScopeCache, existence="unique_per_conduit")
22    root = book.conjure()
23    child = root.create_lesser_conduit()
24    grandchild = child.create_lesser_conduit()
25
26    registries = {id(c.meld(spell=GlobalRegistry))
27                  for c in (root, child, grandchild)}
28    caches = {id(c.meld(spell=ScopeCache))
29              for c in (root, child, grandchild)}
30    assert len(registries) == 1 and len(caches) == 3
31    print("same tree: 1 shared registry, 3 scope-local caches")
32
33
34if __name__ == "__main__":
35    main()

Check the outcome๏ƒ

The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here.

More beginner examples ยท Level guide

API contracts๏ƒ