OOMatch: Pattern Matching as Dispatch in Java

We present a new language feature, specified as an extension to Java. The feature is a form of dispatch, which includes and subsumes multimethods, but which is not as powerful as general predicate dispatch. It is, however, intended to be more practical and easier to use than the latter. The extensio...

Full description

Bibliographic Details
Main Author: Richard, Adam
Language:en
Published: 2007
Subjects:
Online Access:http://hdl.handle.net/10012/3217
id ndltd-LACETR-oai-collectionscanada.gc.ca-OWTU.10012-3217
record_format oai_dc
spelling ndltd-LACETR-oai-collectionscanada.gc.ca-OWTU.10012-32172013-10-04T04:08:13ZRichard, Adam2007-09-11T17:21:03Z2007-09-11T17:21:03Z2007-09-11T17:21:03Z2007http://hdl.handle.net/10012/3217We present a new language feature, specified as an extension to Java. The feature is a form of dispatch, which includes and subsumes multimethods, but which is not as powerful as general predicate dispatch. It is, however, intended to be more practical and easier to use than the latter. The extension, dubbed OOMatch, allows method parameters to be specified as patterns, which are matched against the arguments to the method call. When matches occur, the method applies; if multiple methods apply, the method with the more specific pattern overrides the others. The pattern matching is very similar to that found in the "case" constructs of many functional languages, with an important difference: functional languages normally allow pattern matching over variant types (and other primitives such as tuples), while OOMatch allows pattern matching on Java ob jects. Indeed, the wider goal here is the study of the combination of functional and ob ject-oriented programming paradigms. Maintaining encapsulation while allowing pattern matching is of special importance. Class designers should have the control needed to prevent implementation details (such as private variables) from being exposed to clients of the class. We here present both an informal "tutorial" description of OOMatch, as well as a formal specification of the language, and a proof that the conditions specified guarantee run-time safety.enpredicate dispatchdynamic dispatchpattern matchingmultimethodsJavaOOMatch: Pattern Matching as Dispatch in JavaThesis or DissertationSchool of Computer ScienceMaster of MathematicsComputer Science
collection NDLTD
language en
sources NDLTD
topic predicate dispatch
dynamic dispatch
pattern matching
multimethods
Java
Computer Science
spellingShingle predicate dispatch
dynamic dispatch
pattern matching
multimethods
Java
Computer Science
Richard, Adam
OOMatch: Pattern Matching as Dispatch in Java
description We present a new language feature, specified as an extension to Java. The feature is a form of dispatch, which includes and subsumes multimethods, but which is not as powerful as general predicate dispatch. It is, however, intended to be more practical and easier to use than the latter. The extension, dubbed OOMatch, allows method parameters to be specified as patterns, which are matched against the arguments to the method call. When matches occur, the method applies; if multiple methods apply, the method with the more specific pattern overrides the others. The pattern matching is very similar to that found in the "case" constructs of many functional languages, with an important difference: functional languages normally allow pattern matching over variant types (and other primitives such as tuples), while OOMatch allows pattern matching on Java ob jects. Indeed, the wider goal here is the study of the combination of functional and ob ject-oriented programming paradigms. Maintaining encapsulation while allowing pattern matching is of special importance. Class designers should have the control needed to prevent implementation details (such as private variables) from being exposed to clients of the class. We here present both an informal "tutorial" description of OOMatch, as well as a formal specification of the language, and a proof that the conditions specified guarantee run-time safety.
author Richard, Adam
author_facet Richard, Adam
author_sort Richard, Adam
title OOMatch: Pattern Matching as Dispatch in Java
title_short OOMatch: Pattern Matching as Dispatch in Java
title_full OOMatch: Pattern Matching as Dispatch in Java
title_fullStr OOMatch: Pattern Matching as Dispatch in Java
title_full_unstemmed OOMatch: Pattern Matching as Dispatch in Java
title_sort oomatch: pattern matching as dispatch in java
publishDate 2007
url http://hdl.handle.net/10012/3217
work_keys_str_mv AT richardadam oomatchpatternmatchingasdispatchinjava
_version_ 1716599836992602112