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.
This is the big trick for making the Webel recipe for ADT pseudo classes easily reusable and easy to code against, and works together with:
The pattern is (adapt as needed):
BeginPackage["MY`",{
"W`ADT`ADT`",
(* ... other required ...*)
}
]
$ContextAliases["A`"] =.; (*!!*)
$ContextAliases["A`"] = "W`ADT`ADT`;
Note how the $ContextAliases
gets cleared just for A`
first! Otherwise you'll get a message if you use the same trick in another package.
Example: A package-specific ADT sub-class MY$String
within client package MY`
:
BeginPackage["MY`ADT`",{
ClearAll[MY$String];
pattern = adt$def$ADT[
MY$String,
"Simple ADT String handler example",
MY$String[A`$$_String],
True (*!isAllSuper*)
];
MY$String /: stringLength[pattern] := StringLength[A`$$];
Note the use of A`$$
everywhere throughout the client package! Dr Darren says:
I'm really not into claims of "magical" serendipity, but having the term Abstract Data Type start with an 'A' is rather handy.
If you examine Context[$$]
you'll find it is in fact W`ADT`ADT`$$
(or as adapted). This enables one to pass a 'pattern' involving '$$' cleanly to super definers.