TypeCase
Last edit August 13, 2004
Type case
denotes a
SwitchStatement
-like construct that dispatches not on the value but on the (static or dynamic) type of a value or an object.
The
GangOfFour
VisitorPattern
is a way to implement
DoubleDispatch
on the dynamic type of an object. More generally,
ProgrammingLanguage
s that provide unions or sum types often also provide
PatternMatching
to implement dispatch on the type of an object.
TemplateSpecialization
in
CeePlusPlus
is an example of dispatch on the static type of an object.
See criticism on (Type-)
CaseStatementsConsideredHarmful
Also see
MultipleDispatch
.
CommonLisp
GenericFunction
s dispatch both on the classes and the identities of their arguments.
CategoryLanguageFeature