The Adapter
Bridging incompatible magical interfaces via functional wrappers.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Transmutation // Alteration
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCHEME PATTERN //
;; Old interface
(define (cast-old-spell name power)
(list 'cast name 'with-power power))
;; Adapter for new interface expecting (cast-spell context)
(define (make-spell-adapter name power)
(lambda (context)
(cast-old-spell name (* power (cdr (assq 'boost context))))))
(define adapted (make-spell-adapter 'lightning 10))
(adapted '((boost . 2)))
A simple wrapper function transmutes the old invocation into the new standard, ensuring seamless channeling of aether.
Runic Tags:
#structural
#scheme
#higher-order-functions