The Flyweight
Compressing planar memory by sharing intrinsic state across thousands of ephemeral Gallina Wards.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Condensation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
(* Gallina Ward: Flyweight *)
Require Import String.
(* Intrinsic State (Shared) *)
Record GlyphCore := {
symbol : string;
baseResonance : nat
}.
(* Extrinsic State (Context-dependent) *)
Record CastGlyph := {
core : GlyphCore;
x_pos : nat;
y_pos : nat
}.
Definition FireGlyphCore : GlyphCore := {|
symbol := "Ignis";
baseResonance := 50
|}.
(* Thousands of casts can share the same memory-efficient FireGlyphCore *)
Definition cast1 := {| core := FireGlyphCore; x_pos := 10; y_pos := 20 |}.
Definition cast2 := {| core := FireGlyphCore; x_pos := 15; y_pos := 25 |}.
Runic Tags:
#flyweight
#gallina
#wards