🐎 PONY WARD DIFFICULTY: Adept Structural

The Flyweight Ward

Sharing immaterial essences.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Conjuration // Swarm Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PONY PATTERN //
class val ParticleType
  let color: String
  new create(c: String) => color = c

class Particle
  let _type: ParticleType val
  var _x: F32
  var _y: F32
  new create(t: ParticleType val, x: F32, y: F32) =>
    _type = t
    _x = x
    _y = y

The Flyweight Ward

In Pony, the Flyweight pattern naturally leverages val reference capabilities to safely share intrinsic state across millions of actor/object instances.

Runic Tags: #pony #flyweight