The Visitor
Injecting new arcane operations into an established hierarchy of old words.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Transmutation // Symbiosis
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// B PATTERN //
/* Elements have an accept function pointer */
/* element: [accept_fn, data] */
accept_visitor(element, visitor_fn) {
auto fn;
fn = element[0];
fn(element, visitor_fn);
}
/* The routing */
element_a_accept(self, visitor_fn) {
visitor_fn(self, 'A');
}
/* The concrete Visitor */
print_visitor(element, type) {
if (type == 'A') {
putchar('A'); putchar(element[1]);
}
}
visitation() {
auto el[2];
el[0] = element_a_accept;
el[1] = 'X'; /* data */
accept_visitor(el, print_visitor);
}
Runic Tags:
#b
#design-pattern
#precursor
#bell-labs-magic
#untyped