Singleton (Forth)
The One True Artifact, residing in absolute memory.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Enchantment // Relic-Binding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FORTH PATTERN //
\ Relic-Binding: The Singleton
\ Variables are inherent singletons in Forth.
VARIABLE THE-MONOLITH
: INITIATE-MONOLITH ( -- )
THE-MONOLITH @ 0= IF
999 THE-MONOLITH !
." The Monolith is awakened." CR
ELSE
." The Monolith already exists!" CR
THEN ;
: READ-MONOLITH ( -- val )
THE-MONOLITH @ ;
\ Usage:
\ INITIATE-MONOLITH
\ INITIATE-MONOLITH
\ READ-MONOLITH .
The simplest magic is often the most profound. Every VARIABLE in Forth provides a single memory address, making it a natural Singleton. Guarding its initialization ensures the dark relic is only sparked to life once.
Runic Tags:
#creational
#singleton
#forth
#relics