⚙️ MICHELSON RUNE DIFFICULTY: Adept Creational

The Prototype Pattern in Michelson

Duplicating existing state constructs directly on the stack.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Conjuration // Stackmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MICHELSON PATTERN //
parameter (unit %clone_prototype);
storage (pair (string %prototype) (list string %clones));
code {
  UNPAIR;
  DROP;
  UNPAIR;
  DUP; # The DUP instruction is the essence of Prototype in a stack machine
  DIG 2;
  SWAP; CONS;
  SWAP; PAIR;
  NIL operation; PAIR
}
Runic Tags: #creational #prototype #stack-based smart contracts #michelson #tezos