Abstract
We discuss two interpretations of methods and classes in object-oriented programming and demonstrate a type system based on the notion of methods as graphs. Definitionally, a class may be viewed as a data structure associated with either a collection of method interfaces or a collection of individual methods. In the former interpretation, a method represents a collection of functions that satisfy its interface known as a function space. In the latter interpretation, a method represents a set of input-output pairs of a specific function, called the function's graph. We informally describe and contrast these interpretations with particular emphasis on subtyping rules for methods --- an anti-monotonic rule for the function space interpretation and a monotonic rule for the graph interpretation. These rules have practical implications on type checking, method redefinition, assertions, dynamic binding, and completeness of subtype testing. We present a notation based on the latter interpretation and demonstrate several interesting features of our notation including abstract data types for encapsulation, four kinds of ad-hoc polymorphism (disjoint overloading, coercion, incremental overloading, and specialization), and type restrictions to precisely define the relationship among arguments in polymorphic methods.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.