On this page
Spellframe grouping๏
๐ข Beginner ยท Lesson 09
Spellframes are the grouping key above binding names - one frame key collects a family of related bindings, and (spellframe, binding_name) is the full lookup address.
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/09_spellframe_grouping.py
py -3.14t UX_and_AIX_experiences/01_beginner/09_spellframe_grouping.py
Public surface๏
bind(spellframe=...), meld(spellframe=..., binding_name=...)
Code๏
1"""
2TIER: beginner (09)
3GOAL: Spellframes are the grouping key above binding names - one frame
4 key collects a family of related bindings, and (spellframe,
5 binding_name) is the full lookup address.
6SURFACE EXERCISED: bind(spellframe=...), meld(spellframe=..., binding_name=...)
7"""
8import melder as md
9
10
11class PrimaryStore:
12 role = "primary"
13
14
15class ReplicaStore:
16 role = "replica"
17
18
19class CacheStore:
20 role = "cache"
21
22
23def main() -> None:
24 book = md.Spellbook()
25 book.bind(spell=PrimaryStore, existence="unique",
26 spellframe="storage", binding_name="primary")
27 book.bind(spell=ReplicaStore, existence="unique",
28 spellframe="storage", binding_name="replica")
29 book.bind(spell=CacheStore, existence="unique",
30 spellframe="memory", binding_name="cache")
31 conduit = book.conjure()
32
33 primary = conduit.meld(spell=PrimaryStore, spellframe="storage",
34 binding_name="primary")
35 replica = conduit.meld(spell=ReplicaStore, spellframe="storage",
36 binding_name="replica")
37 cache = conduit.meld(spell=CacheStore, spellframe="memory",
38 binding_name="cache")
39 assert (primary.role, replica.role, cache.role) == (
40 "primary", "replica", "cache")
41 print("frame families resolved: storage(primary, replica) + memory(cache)")
42
43
44if __name__ == "__main__":
45 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.