000109881 001__ 109881
000109881 005__ 20181205220125.0
000109881 0247_ $$2doi$$a10.5075/epfl-thesis-3899
000109881 02470 $$2urn$$aurn:nbn:ch:bel-epfl-thesis3899-9
000109881 02471 $$2nebis$$a5404281
000109881 037__ $$aTHESIS
000109881 041__ $$aeng
000109881 088__ $$a3899
000109881 245__ $$aObject-oriented pattern matching
000109881 269__ $$a2007
000109881 260__ $$aLausanne$$bEPFL$$c2007
000109881 300__ $$a179
000109881 336__ $$aTheses
000109881 502__ $$aDon Syme, Matthias Zenger, Viktor Kuncak
000109881 520__ $$aPattern matching is a programming language construct considered essential in functional programming. Its purpose is to inspect and decompose data. Instead, object-oriented programming languages do not have a dedicated construct for this purpose. A possible reason for this is that pattern matching is useful when data is defined separately from operations on the data – a scenario that clashes with the object-oriented motto of grouping data and operations. However, programmers are frequently confronted with situations where there is no alternative to expressing data and operations separately – because most data is neither stored in nor does it originate from an object-oriented context. Consequently, object-oriented programmers, too, are in need for elegant and concise solutions to the problem of decomposing data. To this end, we propose a built-in pattern matching construct compatible with object-oriented programming. We claim that it leads to more concise and readable code than standard object-oriented approaches. A pattern in our approach is any computable way of testing and deconstructing an object and binding relevant parts to local names. We introduce pattern matching in two variants, case classes and extractors. We compare the readability, extensibility and performance of built-in pattern matching in these two variants with standard decomposition techniques. It turns out that standard object-oriented approaches to decomposing data are not extensible. Case classes, which have been studied before, require a low notational overhead, but expose their representation, making them hard to change later. The novel extractor mechanism offers loose coupling and extensibility, but comes with a performance overhead. We present a formalization of object-oriented pattern matching with extractors. This is done by giving definitions and proving standard properties for a calculus that provides pattern matching as described before. We then give a formal, optimizing translation from the calculus including pattern matching to its fragment without pattern matching, and prove it correct. Finally, we consider non-obvious interactions between the pattern matching and parametric polymorphism. We review the technique of generalized algebraic data types from functional programming, and show how it can be carried over to the object-oriented style. The main tool is the extension of the type system with subtype constraints, which leads to a very expressive metatheory. Through this theory, we are able to express patterns that operate on existentially quantified types purely by universally quantified extractors.
000109881 6531_ $$aprogramming language
000109881 6531_ $$atype systems
000109881 6531_ $$apattern matching
000109881 6531_ $$aobject-oriented programming
000109881 6531_ $$adata abstraction
000109881 6531_ $$asemantics
000109881 6531_ $$acompiler construction
000109881 700__ $$0241083$$aEmir, Burak$$g126743
000109881 720_2 $$0241835$$aOdersky, Martin$$edir.$$g126003
000109881 909C0 $$0252187$$pLAMP$$xU10409
000109881 909CO $$ooai:infoscience.tind.io:109881$$pDOI$$pIC$$pthesis$$pthesis-bn2018$$qDOI2
000109881 918__ $$aIC$$cIIF$$dEDIC2005-2015
000109881 919__ $$aLAMP1
000109881 920__ $$a2007-10-26$$b2007
000109881 970__ $$a3899/THESES
000109881 973__ $$aEPFL$$sPUBLISHED
000109881 980__ $$aTHESIS