1 Objects for Amadeus Gert Smolka Programming Systems Lab, UdS, Saarbrücken August 1999.

Slides:



Advertisements
Similar presentations
Transposing F to C Transposing F to C Andrew Kennedy & Don Syme Microsoft Research Cambridge, U.K.
Advertisements

Chapter 13 Abstraction and inheritance. This chapter discusses n Implementing abstraction. u extension u inheritance n Polymorphism/dynamic binding. n.
More ML Compiling Techniques David Walker. Today More data structures lists More functions More modules.
Lecture 5: Interfaces.
Type Systems and Object- Oriented Programming (III) John C. Mitchell Stanford University.
Object-Oriented Programming. 2 An object, similar to a real-world object, is an entity with certain properties, and with the ability to react in certain.
A little bit on Class-Based OO Languages CS153: Compilers Greg Morrisett.
Cs776 (Prasad)L4Poly1 Polymorphic Type System. cs776 (Prasad)L4Poly2 Goals Allow expression of “for all types T” fun I x = x I : ’a -> ’a Allow expression.
C++ Classes & Data Abstraction
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Object Orientation Chapter SixteenModern Programming Languages, 2nd ed.1 Spring 2012.
Object Orientation Chapter SixteenModern Programming Languages, 2nd ed.1.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Wednesday, 10/2/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/2/02  QUESTIONS (on HW02 – due at 5 pm)??  Today:  Review of parameters  Introduction.
1 Lecture 3 Inheritance. 2 A class that is inherited is called superclass The class that inherits is called subclass A subclass is a specialized version.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Confined Types Encapsulation and modularity Seminar November, 2005 presented by: Guy Gueta.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 The Design of Class Mechanism for MOBY. 2 Earlier Software designers have to choose between the following schemes for the development Earlier Software.
Introduction to ML Last time: Basics: integers, Booleans, tuples,... simple functions introduction to data types This time, we continue writing an evaluator.
1 Introduction to CS Agenda Syllabus Schedule Lecture: the management of complexity.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object and Object- Relational Databases.
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
Inheritance using Java
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
PrasadCS7761 Haskell Data Types/ADT/Modules Type/Class Hierarchy Lazy Functional Language.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
C#C# Classes & Methods CS3260 Dennis A. Fairclough Version 1.1 Classes & Methods CS3260 Dennis A. Fairclough Version 1.1.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Evolving the ML Module System Derek Dreyer Toyota Technological Institute at Chicago April 15, 2004.
Advanced Java Programming CS 537 – Data Structures and Algorithms.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Chapter FifteenModern Programming Languages1 A Second Look At Java.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Chapter SixteenModern Programming Languages1 Object Orientation.
1 9/6/05CS360 Windows Programming CS360 Windows Programming.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
CSE 3302 Programming Languages Chengkai Li, Weimin He Spring 2008 Abstract Data Types and Modules Lecture 11 – ADT and Modules, Spring CSE3302 Programming.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Faithful mapping of model classes to mathematical structures Ádám Darvas ETH Zürich Switzerland Peter Müller Microsoft Research Redmond, WA, USA SAVCBS.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
ISBN Chapter 12 Support for Object-Oriented Programming.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Principles of programming languages 10: Object oriented languages
OOP: Encapsulation &Abstraction
Classes (Part 1) Lecture 3
Classes C++ representation of an object
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Winter 2013.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2016.
Advanced Java Programming
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2017.
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Classes C++ representation of an object
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2013.
Inheritance Lakshmish Ramaswamy.
CSE341: Programming Languages Lecture 25 Subtyping for OOP; Comparing/Combining Generics and Subtyping Dan Grossman Spring 2019.
Presentation transcript:

1 Objects for Amadeus Gert Smolka Programming Systems Lab, UdS, Saarbrücken August 1999

2 Sources User's Manual, OCaml Release 2.02 (March 1999) Objective ML: An effective object-oriented extension to ML, D. Rémy and Jérôme Vouillon. Theory and Practice of Object Systems,(4)1:27-50,1998. Principles and a Preliminary Design for ML2000, ML2000 Working Group, March 1999 The Design of a Class Mechanism for MOBY, Kathleen Fischer and John Reppy. POPL 1999.

3 External View Use of Objects Internal View Creation of Objects Object Types

4 Types as Interfaces int -> int Function types do not fix implementation Abstract types do Object types strengthen types-as-interfaces property –record expressivity –subtyping (can forget fields) –partial type abstraction –higher-order polymorphism

5 Object Type for Stacks type intStack = unit; get : int; empty : bool >

6 Parameterisation type 'a stack = unit; get : 'a; empty : bool >

7 Recursion type 'a stack = unit; get : 'a; empty : bool; clone : 'a stack >

8 Polymorphic Methods type 'a stack = < put : 'a -> unit; get : 'a; empty : bool; map : ['b] ('a -> 'b) -> 'b stack >

9 Object Types have Structural Equality type 'a stack = < put : 'a -> unit; get : 'a; empty : bool; clone : 'a stack > type 'a queue = < put : 'a -> unit; get : 'a; empty : bool; clone : 'a queue > Definitions of object types are non-generative Type constructors stack and queue are equal Cannot separate stacks from queues

10 Partial Type Abstraction sig type 'a stack :> unit; get : 'a; empty : bool > val stack : unit -> 'a stack end Generative Can reveal abstract supertypes

11 Subtype Ordering Nonprimitive type constructors are invariant width depth

12 Type Inference Derives omitted type annotations and type checks Type weakenings must be annotated:  exp Constraints for method selections and type weakenings are delayed until enough information is available Conservative extension of ML-style type inference Clever use of type abbreviations

13 Object-oriented Modelling versus ADTs concise: e#m e' rather than S.m e e' higher-order interfaces are types rather than signatures

14 External View Use of Objects Internal View Creation of Objects Object Types

15 Object Creation Objects have generative equality Method declarations define pre-methods fn self => exp that are applied to object upon method selection self provides recursion object(self) method m = exp... end

16 Class Declarations class claid = fn pat => object(self) inheritance declarations field declarations method declarations initializers end new claid

17 Class Declarations Needed for inheritance Methods can be overriden (with subtype) self only visible in method declarations and initializers Classes have status similar to structures Class specifications for signatures Protected methods are straightforward Private methods are semantically non-obvious Class identifier is automatically overloaded as type identifier for the respective object type

18 Field Declarations Analogous to value declarations of core language Do not see self Do not contribute to object type (i.e, fields are protected) Are inherited Are not overriden Private fields Mutable fields (important for cloning)

19 Super inherit classid exp as super super#m can be used in method declarations and initializers

20 Cloning class c = object val mutable x = 0 method inc = x<-1 method clone = { } end

21 Self Types in Class Interfaces class('a) val x : int; method movex : int -> 'a end class point1 = object val x = 0 method movex d = { } end class point2 = object inherit point1 val y = 0 method movey d = { } end class('a) val x : int; val y : int; method movex : int -> 'a; method movey : int -> 'a end

22 Differences to Objective Caml No partial type abstraction Open object types Fields as instance variables Functional objects Abstract classes and methods

23 Open Object Types Can express most general type of method selection #m -> 'a Can express most general type of cloning function ( as 'a) -> 'a Can express general type of min function ( as 'a) * 'a -> 'a Subtype ordering defined as one would expect

24 Binary Methods Expose Internals sig type t type point = unit; distance : point -> real; rep : t > val new : real * real -> point end Alternative: partial type abstraction