The Prototype (Racket)
Clone existing parenthetical entities to bypass the expensive summoning rituals.
β§ GANG OF FOUR LINEAGE & ARCANUM β§
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// RACKET PATTERN //
#lang racket
(struct spell (name mana damage) #:transparent)
(define fireball (spell "Fireball" 50 100))
(define (clone-spell s #:name [name (spell-name s)]
#:mana [mana (spell-mana s)]
#:damage [damage (spell-damage s)])
(spell name mana damage))
(define greater-fireball (clone-spell fireball #:name "Greater Fireball" #:damage 200))
(printf "Base Spell: ~a\n" fireball)
(printf "Cloned Spell: ~a\n" greater-fireball)
The Prototype
Why conjure from scratch when you can duplicate? The Prototype pattern relies on the power of structural cloning. In Racket, keyword arguments allow us to selectively mutate the cloned structure, creating a βGreaterβ variant of a base spell while leaving the original intact. Itβs an illusion that becomes reality.
Runic Tags:
#racket
#creational
#prototype
#structural-magic