Objects as Session-Typed Processes

Similar documents
Objects as Session-Typed Processes

Principles of Programming Languages, 2

A Rehabilitation of Message-Passing Concurrency

CSE Lecture 3: Objects 2 September Nate Nystrom University of Texas at Arlington

Software Architecture

Meta-programming with Names and Necessity p.1

On to Objects. CIS 500 Software Foundations Fall November 20. A Change of Pace. Case study: object-oriented programming

Object Model. Object Orientated Analysis and Design. Benjamin Kenwright

Object Oriented Paradigm

CS-XXX: Graduate Programming Languages. Lecture 23 Types for OOP; Static Overloading and Multimethods. Dan Grossman 2012

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Lecture Notes on Session Types

Intersections and Unions of Session Types

CS558 Programming Languages

Incremental Reasoning for Multiple Inheritance

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

CMPT Data and Program Organization

Com S 541. Programming Languages I

CS-XXX: Graduate Programming Languages. Lecture 22 Class-Based Object-Oriented Programming. Dan Grossman 2012

CS558 Programming Languages

Don t Believe the Hype. CS152: Programming Languages. Lecture 21 Object-Oriented Programming. Class-based OOP. So what is OOP?

CS153: Compilers Lecture 11: Compiling Objects

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Concepts of Programming Languages

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Object Oriented Programming

3. Object-Oriented Databases

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

CIS 500 Software Foundations Fall December 6

Administrivia. Existential Types. CIS 500 Software Foundations Fall December 6. Administrivia. Motivation. Motivation

Semantic Analysis Type Checking

Object Orientation. Chapter Sixteen Modern Programming Languages, 2nd ed. 1

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors.

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Back to OCaml. Summary of polymorphism. Example 1. Type inference. Example 2. Example 2. Subtype. Polymorphic types allow us to reuse code.

CS152: Programming Languages. Lecture 23 Advanced Concepts in Object-Oriented Programming. Dan Grossman Spring 2011

Cunning Plan. One-Slide Summary. Functional Programming. Functional Programming. Introduction to COOL #1. Classroom Object-Oriented Language

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Data Abstraction. Hwansoo Han

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes

Last time: generic programming

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

CSE 307: Principles of Programming Languages

Pierce Ch. 3, 8, 11, 15. Type Systems

Object-Oriented Technology. Rick Mercer

Computer Science 4U Unit 1. Programming Concepts and Skills Modular Design

Object-Oriented Programming. Lecture 16 CS 565 4/10/08

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Object Oriented Programming: Based on slides from Skrien Chapter 2

CS558 Programming Languages Winter 2013 Lecture 8

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Chapter3: Introduction to Classes and Objects

Lecture 23: Object Lifetime and Garbage Collection

CSCI-GA Scripting Languages

"Object Oriented" Programming using ML

CHAPTER 5 GENERAL OOP CONCEPTS

Featherweight Scala. Week 14

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

More Static Semantics. Static. One-Slide Summary. Lecture Outline. Typing Rules. Dispatch Rules SELF_TYPE

Grade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline

Thanks! Review. Course Goals. General Themes in this Course. There are many programming languages. Teaching Assistants. John Mitchell.

Programming Languages 2nd edition Tucker and Noonan"

CSE 307: Principles of Programming Languages

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

Parallel Complexity Analysis with Temporal Session Types

Chapter 12 Object and Object Relational Databases

Functional Programming. Introduction To Cool

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Topic 9: Type Checking

Topic 9: Type Checking

Axiomatic Specification. Al-Said, Apcar, Jerejian

The Road to Object Orientation Operating Systems Object Planes. Object Planes. David Chisnall. March 25, 2010

Message Passing. Advanced Operating Systems Tutorial 7

Modules Matter Most. Robert Harper Carnegie Mellon University. MacQueen Fest Chicago May 2012

Compiler Construction

CPS 506 Comparative Programming Languages. Programming Language

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Generic polymorphism on steroids

Programming Paradigms

Lecturer: William W.Y. Hsu. Programming Languages

A STUDY OF OBJECT ORIENTED ANALYSIS AND DESIGN

Practical Affine Types and Typestate-Oriented Programming

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich

Comp 311 Principles of Programming Languages Lecture 21 Semantics of OO Languages. Corky Cartwright Mathias Ricken October 20, 2010

Fundamentals of Programming Session 13

Object-oriented perspective

Part III. Chapter 15: Subtyping

Programming Safe Agents in Blueprint. Alex Muscar University of Craiova

SAP ABAP Training Course Content :

Key components of a lang. Deconstructing OCaml. In OCaml. Units of computation. In Java/Python. In OCaml. Units of computation.

Goals of the Lecture OO Programming Principles

Recap: Functions as first-class values

Combining Programming with Theorem Proving

Parallel Complexity Analysis with Temporal Session Types

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

Chapter 4 Defining Classes I

Programming Languages (PL)

Transcription:

Objects as Session-Typed Processes Stephanie Balzer and Frank Pfenning Computer Science Department, Carnegie Mellon University AGERE! 2015

The essence of object-orientation 2

The essence of object-orientation 39 concepts ( quarks ) of object-orientation [Armstrong06]: object, encapsulation, message passing, information hiding, dynamic dispatch, reuse, modularization, inheritance, etc. 2

The essence of object-orientation 39 concepts ( quarks ) of object-orientation [Armstrong06]: object, encapsulation, message passing, information hiding, dynamic dispatch, reuse, modularization, inheritance, etc. Object-orientation in its inception: Objects encapsulate state (Simula) Objects interact by message exchange (Smalltalk, Actor model) 2

The essence of object-orientation 39 concepts ( quarks ) of object-orientation [Armstrong06]: object, encapsulation, message passing, information hiding, dynamic dispatch, reuse, modularization, inheritance, etc. Object-orientation in its inception: Objects encapsulate state (Simula) Objects interact by message exchange (Smalltalk, Actor model) Object-orientation to Alan Kay [public email]: OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I m not aware of them. 2

The essence of object-orientation Objects encapsulate state Computation by message exchange Messages are exchanged simultaneously State transitions due to message exchange 3

The essence of object-orientation Objects encapsulate state Computation by message exchange Messages are exchanged simultaneously State transitions due to message exchange Suggested model of computation: inherently concurrent allows expression of valid sequences of state transitions 3

This paper in a nutshell A fresh look at object-oriented programming: Objects as processes Objects interact by sending messages along channels, where objects are identified with offering channel Channels (and offering object) are typed by linear session types, making client own the offering object We introduce the programming language CLOO and show that: typical oo patterns (dynamic dispatch, subtyping) arise naturally new forms of expression (type-directed reuse, internal choice) emerge Important concern: Support program reasoning, whilst maintaining object-oriented style 4

Contributions Concurrent message-passing programming model with: static protocol assurance absence of data races and deadlocks Object-oriented programming model with: typical oo concepts (encapsulation, dynamic dispatch, subtyping) new forms of expressions (type-directed reuse, internal choice) Prototype compiler: Supports most of presented features Progress and preservation proof (in meantime): for core subset of language 5

Outline Background: linear session types Basic correspondence between CLOO - object-oriented concepts: Objects as processes Dynamic dispatch Structural subtyping New forms of expression: Type-directed delegation Internal Choice Conclusions 6

Outline Background: linear session types Basic correspondence between CLOO - object-oriented concepts: Objects as processes Dynamic dispatch Structural subtyping New forms of expression: Type-directed delegation Internal Choice Conclusions 6

Linear session-based communication client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 7

Linear session-based communication session type defines protocol client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 8

Linear session-based communication <! int; > client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 9

Linear session-based communication output <! int; > client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 9

Linear session-based communication <! int; > client process (object s owner) c 10 bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 9

Linear session-based communication <! int; > client process (object s owner) 10 c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 9

Linear session-based communication client process 10 (object s owner) [Based on intuitionistic linear sequent calculus] 9

Linear session-based communication client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 10

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 10

Linear session-based communication read-once counter: input ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 10

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 10

Linear session-based communication read-once counter: recursive session type ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 10

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) Inc c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 11

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel Inc offering process (object) [Based on intuitionistic linear sequent calculus] 11

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 11

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) Val c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 12

Linear session-based communication read-once counter: ctr =?{<!int; > Val; <ctr> Inc} client process (object s owner) c bidirectional channel Val offering process (object) [Based on intuitionistic linear sequent calculus] 12

Linear session-based communication read-once counter: <!int; > client process (object s owner) c bidirectional channel offering process (object) [Based on intuitionistic linear sequent calculus] 12

Linear session-based communication client process (object s owner) c offering process (object) [Based on intuitionistic linear sequent calculus] 13

Linear session-based communication c [Based on intuitionistic linear sequent calculus] 14

Linear session-based communication g d c h [Based on intuitionistic linear sequent calculus] 14

Linear session-based communication linearity: channels as resources g d c h [Based on intuitionistic linear sequent calculus] 15

Linear session-based communication linearity: channels as resources g d c d c g, h h [Based on intuitionistic linear sequent calculus] 15

Linear session-based communication linearity: channels as resources g d c g d c g, h h [Based on intuitionistic linear sequent calculus] 16

Linear session-based communication linearity: channels as resources g d g c d c g, h h [Based on intuitionistic linear sequent calculus] 16

Linear session-based communication linearity: channels as resources g d c d c, g h h [Based on intuitionistic linear sequent calculus] 16

Linear session-based communication linearity: channels as resources g d c d c, g h h [Based on intuitionistic linear sequent calculus] 16

Linear session-based communication linearity: channels as resources g d c d c, g h h Processes form (dynamically changing) tree [Based on intuitionistic linear sequent calculus] 16

Linear session-based communication linearity: channels as resources g d c d c, g h h [Based on intuitionistic linear sequent calculus] 17

Linear session-based communication linearity: channels as resources g d c d c, g h h Linearity guarantees session fidelity and freedom from data races and deadlock [Based on intuitionistic linear sequent calculus] 17

Outline Background: linear session types Basic correspondence between CLOO - object-oriented concepts: Objects as processes Dynamic dispatch Structural subtyping New forms of expression: Type-directed delegation Internal Choice Conclusions 18

Session types in CLOO typedef <?choice ctr> ctr; // external choice choice ctr { <ctr> Inc; // increment value, continue <!int; > Val; // send value, terminate }; 19

Session types in CLOO typedef <?choice ctr> ctr; // external choice choice ctr { <ctr> Inc; // increment value, continue <!int; > Val; // send value, terminate }; choice 19

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; 20

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} 20

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client h1 h2 h3 eps 20

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} offering channel client h1 h2 h3 eps 20

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client h1 h2 h3 eps 21

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} channel resources client h1 h2 h3 h1 h2 h3 eps 21

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client h1 h2 h3 h1 h2 h3 eps 21

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} local state client 1 h1 0 h2 1 h3 h1 h2 h3 eps 22

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 1 h1 0 h2 1 h3 h1 h2 h3 eps 22

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} 5 = 1 2 0 0 2 1 1 2 2 client 1 h1 0 h2 1 h3 h1 h2 h3 eps 22

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 1 h1 0 h2 1 h3 h1 h2 h3 eps 23

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 1 h3 h1 h2 h3 eps 24

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 1 h3 h1 h2 h3 eps 24

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} if (b == false) { b = true; } else { $h.inc; b = false; } client 0 h1 0 h2 1 h3 h1 h2 h3 eps 24

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 h1 h2 h3 eps 25

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l (bool b, ctr $h) { loop { switch ($l) { case Inc: ; case Val: ; }}} ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 h1 h2 h3 eps 25

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 h1 h2 h3 eps 25

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $z = eps(); $l = (true, $z); ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 h1 h2 h3 eps 25

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $z = eps(); $l = (true, $z); ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 h4 h1 h2 h3 eps eps 25

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $z = eps(); $l = (true, $z); ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 1 h4 h1 h2 h3 h4 eps 26

Process implementations in CLOO session type: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; process implementation as string: ctr $z = eps(); $l = (true, $z); ctr $l eps() { loop { switch ($l) { case Inc: ; case Val: ; }}} client 0 h1 0 h2 0 h3 1 h4 Dynamic dispatch of labels h1 h2 h3 h4 eps 26

Basic correspondence Objects as processes A process has state and identity. Process state: local + protocol. Processes are encapsulated Process local state can only be read or written by process. Protocol state can only be changed by message exchange. Method invocations as receives of labels from external choice Processes also permit sends of labels from internal choice. References as channels Channels are bidirectional and linear. Ownership transfer possible. 27

Structural subtyping typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; 28

Structural subtyping supertype: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; subtype: typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; 28

Structural subtyping supertype: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; subtype: typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; ctr_inc2 is a subtype of ctr, it accepts at least same choices 28

Structural subtyping supertype: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; subtype: typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; ctr_inc2 is a subtype of ctr, it accepts at least same choices subtyping arises between external and internal choices 28

Outline Background: linear session types Basic correspondence between CLOO - object-oriented concepts: Objects as processes Dynamic dispatch Structural subtyping New forms of expression: Type-directed delegation Internal Choice Conclusions 29

Type-directed delegation supertype: subtype: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; 30

Type-directed delegation supertype: subtype: process: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; ctr_inc2 $c counter_inc2(ctr $d) { loop { switch ($c) { case Inc2: $d.inc; $d.inc; break; default: $c <=> $d; // type-directed delegation to d' }}} 30

Type-directed delegation supertype: subtype: process: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; ctr_inc2 $c counter_inc2(ctr $d) { loop { switch ($c) { case Inc2: $d.inc; $d.inc; break; default: $c <=> $d; // type-directed delegation to d' }}} 30

Type-directed delegation supertype: subtype: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; typedef <?choice ctr_inc2> ctr_inc2; choice ctr_inc2 { <ctr_inc2> Inc; <ctr_inc2> Inc2; <!int; > Val; }; inferable process: from session type declaration and subtyping relationship ctr_inc2 $c counter_inc2(ctr $d) { loop { switch ($c) { case Inc2: $d.inc; $d.inc; break; default: $c <=> $d; // type-directed delegation to d' }}} 30

Internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; 31

Internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; 31

Internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; Bit string is represented in terms of Bit and Eps messages, rather than and eps processes 31

External vs internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; ctr $l (bool b, ctr $h) { } ctr $l eps() { } string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; s $succ inc(s $ctr) { } <!int;> $val val(s $ctr) { } s $zero zero() { } 32

External vs internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; ctr $l (bool b, ctr $h) { } ctr $l eps() { } string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; s $succ inc(s $ctr) { } <!int;> $val val(s $ctr) { } s $zero zero() { } 32

External vs internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; ctr $l (bool b, ctr $h) { } ctr $l eps() { } string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; 32

External vs internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; ctr $l (bool b, ctr $h) { } ctr $l eps() { } string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; Lead to different program modularization 32

External vs internal choice string as external choice: typedef <?choice ctr> ctr; choice ctr {<ctr> Inc; <!int; > Val;}; ctr $l (bool b, ctr $h) { } ctr $l eps() { } string as internal choice: typedef <!choice s> s; choice s {<> Eps; <!bool; s> Bit;}; Lead to different program modularization External choice facilitates addition of new variants, internal choice addition of new operations 32

Conclusions A fresh look at object-oriented programming accommodates existing and new object-oriented features inherently concurrent and protocol-aware Ongoing work: compiler support of subtyping and type-directed delegation extend formalization Future work: polymorphism for generic data structures affine and shared channels shared channels combined with traditional locking primitives 33