Mathematica: Webel ADT pseudo classes: DEFINITION/CONVENTION: Functions that populate ADTs with reusable ADT-method UpValues are called 'definers' and include '$def' in the name after a Package scope indicator: Example: adt$def$ADT, my$def$MY$CleverList

Webel IT Australia promotes the amazing Mathematica tool and the powerful Wolfram Language and offers professional Mathematica services for computational computing and data analysis. Our Mathematica tips, issue tracking, and wishlist is offered here most constructively to help improve the tool and language and support the Mathematica user community.
DISCLAIMER: Wolfram Research does not officially endorse analysis by Webel IT Australia.
Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
Webel Mathematica keywords
Keywords

A Webel definer is a top-level (non "ADT-method") function that accepts a unique signature pattern (which uniquely defines each Webel ADT pseudo class), and typically populates it with reusable UpValues.

The name definer was chosen in part to avoid comparison with a constructor in fully-fledged OO.

Using the universal base ADT definer as an example):


adt$def$ADT[
  class_Symbol,
  $usage_String,
  pattern_,
  isAllSuper:(True|False):False
] := Module[{ ...},
...
  class /: get[pattern] := $$;
  class /: head[pattern] := Head[$$];
...
  pattern
];

pattern = adt$def$ADT[MY$ADT$String,
  "An ADT that carries a String",
  MY$ADT$String[$$_String],
  True
];
MY$ADT$String /: stringLength[pattern] := StringLength[$$]; 

my$adt$s = MY$ADT$String["string1"];

stringLength[my$adt$s]

7
Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)