🕰️ SIMULA GENESIS DIFFICULTY: Archmage Behavioral

The Visitor Incantation in Simula

Adding new operations to an ancient hierarchy without defiling its classes.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Conjuration // Visitation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SIMULA PATTERN //
Begin
    Class Visitor;
    Virtual: Procedure VisitElementA(e), VisitElementB(e); Ref(ElementA) e; Ref(ElementB) e;
    Begin
    End;

    Class Element;
    Virtual: Procedure Accept(v); Ref(Visitor) v;
    Begin
    End;

    Element Class ElementA;
    Begin
        Procedure Accept(v); Ref(Visitor) v; v.VisitElementA(This ElementA);
    End;
End;

When the ancient classes are sealed and sacred, the Visitor allows one to traverse the hierarchy, performing new and wondrous incantations on the elements without permanently etching the changes into their structure.

Runic Tags: #simula #gof #behavioral #visitation