Memento (Forth)
Snapshot the stack state to cheat death itself.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Memento
ARCANUM SCHOOL: Chronomancy // Time-Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FORTH PATTERN //
\ Time-Weaving: The Memento
\ Saving and restoring variables or stack depth.
VARIABLE TIMELINE-HP
VARIABLE SAVED-HP
: SET-HP ( n -- ) TIMELINE-HP ! ;
: SAVE-TIMELINE ( -- )
TIMELINE-HP @ SAVED-HP !
." Timeline preserved." CR ;
: RESTORE-TIMELINE ( -- )
SAVED-HP @ TIMELINE-HP !
." Time reversed. HP restored." CR ;
\ Usage:
\ 100 SET-HP SAVE-TIMELINE
\ 0 SET-HP \ Death!
\ RESTORE-TIMELINE
The Memento pattern allows the adept to snapshot an object’s internal state. In Forth, this is the literal capturing of VARIABLEs or entire blocks of memory, locking the timeline away so it can be restored when the ritual inevitably goes wrong.
Runic Tags:
#behavioral
#memento
#forth
#time-magic