Adding Pattern Matching to Existing Object-Oriented Languages

نویسندگان

  • Sukyoung Ryu
  • Changhee Park
  • Guy L. Steele
چکیده

While object-oriented languages are designed for information hiding and data encapsulation, intensive data manipulation often calls for pattern matching, one of the main features of functional programming languages. Pattern matching provides a concise way to describe specific structures or conditions of objects so that programmers can clearly identify and easily access the corresponding objects. The need for both object information hiding and pattern matching over objects, which are seemingly conflicting features, shows up very well in the problem of language manipulation. In the compiler development of Fortress, a new object-oriented language with extensive support for functional programming, we originally implemented the Fortress type checker in Java. However, because Java does not provide pattern matching, we reimplemented the type checker in Scala. Compared to the pattern matching mechanism in Scala, Java’s visitor patterns are verbose, make it hard to capture the high-level specification of objects, and are nontrivial to maintain. In this paper, we introduce a new pattern-matching mechanism which can be added to existing object-oriented languages. We present the mechanism currently being implemented as an addition to the Fortress programming language. The mechanism provides a concise way of describing and using patterns in the presence of runtime manipulation of types using typecase and multimethods, unlike Scala which has type-erasure semantics. Even though it is premature to discuss the performance and scalability of the presented mechanism, we believe that the same optimization techniques used in Scala will apply to our mechanism.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Translation of Pattern Matching in a Java-like Language

Patternmatching is a programming language construct that is common in functional programming but somewhat less popular in object-oriented languages. The present paper gives an overview of issues that arise when adding pattern matching to an object-oriented language like Java.

متن کامل

Matching Objects Without Language Extension

Pattern matching is a powerful programming concept which has proven its merits in declarative programming. The absence of pattern-matching in object-oriented programming languages is felt especially when tackling source code processing problems. But existing proposals for pattern matching in such languages rely on language extension, which makes their adoption overly intrusive. We propose an ap...

متن کامل

R++: Adding Path-Based Rules to C++

Object-oriented languages and rule-based languages ooer two distinct and useful programming abstractions. However, previous attempts to integrate data-driven rules into object-oriented languages have typically achieved an uneasy union at best. R++ is a new, closer integration of the rule-based and object-oriented paradigms that extends C++ with a single programming construct, the path-based rul...

متن کامل

Declaring Classes in Pattern Calculus

Pattern calculus is able to represent a fixed system of classes by treating methods as pattern-matching functions, along with a powerful account of both quantified types and of subtypes. This paper adds class, and subclass declarations to support an evolving class hierarchy. Even though method meanings change as new classes are introduced, the properties of existing programs do not change. This...

متن کامل

Matching Scores of System Relevance and User-Oriented Relevance in SID, ISC and Google Scholar

Background and Aim: The main aim of Information storage and retrieval systems is keeping and retrieving the related information means providing the related documents with users’ needs or requests. This study aimed to answer this question that how much are the system relevance and User- Oriented relevance are matched in SID, SCI and Google Scholar databases. Method: In this study 15 keywords of ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2010