Type Case

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, ProgrammingLanguages 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 GenericFunctions dispatch both on the classes and the identities of their arguments.


CategoryLanguageFeature


EditText of this page (last edited August 13, 2004) or FindPage with title or text search