Gregor Bethlen

Size: px
Start display at page:

Download "Gregor Bethlen"

Transcription

1 Universität Karlsruhe Slide 1 of 22

2 Outline 1 Motivation Examples Conclusions 2 BGGA CICE FCM 3 Slide 2 of 22

3 Motivation Motivation Examples Conclusions treat functions/methods as values for variables and parameters of methods ease the passing of callback-functions treat some situations more elegantly (for example one object acting as an observer twice) ease for example the creation of threads obsolete several (API-)interfaces which only exist due to the present absence of closures in parametrise algorithms with functions Slide 3 of 22

4 Motivation Motivation Examples Conclusions treat functions/methods as values for variables and parameters of methods ease the passing of callback-functions treat some situations more elegantly (for example one object acting as an observer twice) ease for example the creation of threads obsolete several (API-)interfaces which only exist due to the present absence of closures in parametrise algorithms with functions Slide 3 of 22

5 Motivation Motivation Examples Conclusions treat functions/methods as values for variables and parameters of methods ease the passing of callback-functions treat some situations more elegantly (for example one object acting as an observer twice) ease for example the creation of threads obsolete several (API-)interfaces which only exist due to the present absence of closures in parametrise algorithms with functions Slide 3 of 22

6 Motivation Motivation Examples Conclusions treat functions/methods as values for variables and parameters of methods ease the passing of callback-functions treat some situations more elegantly (for example one object acting as an observer twice) ease for example the creation of threads obsolete several (API-)interfaces which only exist due to the present absence of closures in parametrise algorithms with functions Slide 3 of 22

7 Motivation Motivation Examples Conclusions treat functions/methods as values for variables and parameters of methods ease the passing of callback-functions treat some situations more elegantly (for example one object acting as an observer twice) ease for example the creation of threads obsolete several (API-)interfaces which only exist due to the present absence of closures in parametrise algorithms with functions Slide 3 of 22

8 Motivation Motivation Examples Conclusions treat functions/methods as values for variables and parameters of methods ease the passing of callback-functions treat some situations more elegantly (for example one object acting as an observer twice) ease for example the creation of threads obsolete several (API-)interfaces which only exist due to the present absence of closures in parametrise algorithms with functions Slide 3 of 22

9 Syntax Motivation Examples Conclusions our examples use a syntax like the one proposed in First-class methods: -style closures we have function-types like #(double(int, int)) for functions taking two integers and return a double we have (anonymous) inner methods like #(int a, int b) { return (double)(a + b) / 2; Slide 4 of 22

10 Syntax Motivation Examples Conclusions our examples use a syntax like the one proposed in First-class methods: -style closures we have function-types like #(double(int, int)) for functions taking two integers and return a double we have (anonymous) inner methods like #(int a, int b) { return (double)(a + b) / 2; Slide 4 of 22

11 Syntax Motivation Examples Conclusions our examples use a syntax like the one proposed in First-class methods: -style closures we have function-types like #(double(int, int)) for functions taking two integers and return a double we have (anonymous) inner methods like #(int a, int b) { return (double)(a + b) / 2; Slide 4 of 22

12 Examples Motivation Examples Conclusions We can assign and invoke #(double(int, int)) avg = #(int a, int b) { return (double)(a + b) / 2; ; double result = avg.invoke(3, 10); with the result 6.5. Slide 5 of 22

13 Examples Motivation Examples Conclusions An example without a local variable in the definition-context. public #(int(int)) getaddtwo() { #(int(int)) addtwo = #(int a) { return a + 2; ; return addtwo; public void f() { #(int(int)) closure = getaddtwo(); int result = closure.invoke(33); //result is 35 Slide 6 of 22

14 Examples Motivation Examples Conclusions An example with a local variable in the definition-context. public #(int(int)) getaddx(int x) { int summand = x; #(int(int)) addx = #(int a) { return a + summand; ; return addx; public void f() { #(int(int)) closure = getaddx(4); int result = closure.invoke(33); //result is 37 Slide 7 of 22

15 Examples Motivation Examples Conclusions An example with a local variable in the definition-context which value is changed after the closure-definition. public #(int(int)) getaddx(int x) { int summand = x; #(int(int)) addx = #(int a) { return a + summand; ; summand = 17; return addx; public void f() { #(int(int)) closure = getaddx(4); int result = closure.invoke(33); //result is 50 Slide 8 of 22

16 Impacts for local variables Motivation Examples Conclusions We conclude that local variables of a definition-context, which are used in a closure, can not be put on the stack; they must go on the heap. The same holds for references/pointers to objects. Slide 9 of 22

17 Impacts for verification Motivation Examples Conclusions It is not possible to treat a local variable var used in method meth of object obj as a synthetic private attribute obj.meth_var, as one may think. Let there be a closure defined in meth using var. If obj.meth gets called twice, each created closure-instance will use its own version of var. Slide 10 of 22

18 Impacts for verification Motivation Examples Conclusions It is not possible to treat a local variable var used in method meth of object obj as a synthetic private attribute obj.meth_var, as one may think. Let there be a closure defined in meth using var. If obj.meth gets called twice, each created closure-instance will use its own version of var. Slide 10 of 22

19 All proposals BGGA CICE FCM it is possible to convert function-types to interface types with single abstract methods (sometimes called SAM-types) this way closures can be passed for example to the constructor of Thread, new Thread(#(void) { aclient->startwork() ). this is useful for all kind of callback-functions, which in are modelled by SAM-types; even the design pattern»observer«uses this detour. the conversion exists due to compatiblity with the current emulation of closures by SAM-types Slide 11 of 22

20 All proposals BGGA CICE FCM it is possible to convert function-types to interface types with single abstract methods (sometimes called SAM-types) this way closures can be passed for example to the constructor of Thread, new Thread(#(void) { aclient->startwork() ). this is useful for all kind of callback-functions, which in are modelled by SAM-types; even the design pattern»observer«uses this detour. the conversion exists due to compatiblity with the current emulation of closures by SAM-types Slide 11 of 22

21 All proposals BGGA CICE FCM it is possible to convert function-types to interface types with single abstract methods (sometimes called SAM-types) this way closures can be passed for example to the constructor of Thread, new Thread(#(void) { aclient->startwork() ). this is useful for all kind of callback-functions, which in are modelled by SAM-types; even the design pattern»observer«uses this detour. the conversion exists due to compatiblity with the current emulation of closures by SAM-types Slide 11 of 22

22 All proposals BGGA CICE FCM it is possible to convert function-types to interface types with single abstract methods (sometimes called SAM-types) this way closures can be passed for example to the constructor of Thread, new Thread(#(void) { aclient->startwork() ). this is useful for all kind of callback-functions, which in are modelled by SAM-types; even the design pattern»observer«uses this detour. the conversion exists due to compatiblity with the current emulation of closures by SAM-types Slide 11 of 22

23 BGGA BGGA CICE FCM The BGGA-Proposal by Gilad Bracha, Neal Gafter, James Gosling and Peter von der Ahé uses an implicit return, like in { int x, int y => x := x + 2; y := y + 2; x + y The return value of a closure is the value of the last expression. Slide 12 of 22

24 BGGA BGGA CICE FCM The proposal does not only introduce method-calls in the functionality we have seen so far. Furthermore there are user-defined control-structures, like withprotocol(aprotocol) { System.out.println("A"); System.out.println("B"); Slide 13 of 22

25 User-defined control-structures BGGA CICE FCM A possible implementation for withprotocol and an invocation of withprotocol with the techniques we have seen so far. public static withprotocol(protocol protocol, {=> void body) { protocol.inform(); body.invoke(); protocol.inform(); withprotocol(aprotocol, {=> System.out.println("A"); System.out.println("B"); ); Slide 14 of 22

26 User-defined control-structures BGGA CICE FCM A possible implementation for withprotocol (unchanged) and an invocation of withprotocol with the proposed improved syntax. public static withprotocol(protocol protocol, {=> void body) { protocol.inform(); body.invoke(); protocol.inform(); withprotocol(aprotocol) { System.out.println("A"); System.out.println("B"); Slide 15 of 22

27 User-defined control-structures Behavior of return and this We have to be aware of the target of return (improved and regular syntax). This holds for this, too. BGGA CICE FCM withprotocol(aprotocol) { System.out.println("A"); if (strangeerror) return; System.out.println("B"); withprotocol(aprotocol, {=> System.out.println("A"); if (strangeerror) return; System.out.println("B"); ); Slide 16 of 22 We can even jump out of scope.

28 User-defined control-structures Behavior of return and this We have to be aware of the target of return (improved and regular syntax). This holds for this, too. BGGA CICE FCM withprotocol(aprotocol) { System.out.println("A"); if (strangeerror) return; System.out.println("B"); withprotocol(aprotocol, {=> System.out.println("A"); if (strangeerror) return; System.out.println("B"); ); Slide 16 of 22 We can even jump out of scope.

29 User-defined control-structures Behavior of continue and break BGGA CICE FCM We have to be aware of the target of break (improved syntax). while (!done) { withprotocol(aprotocol) { System.out.println("A"); if (strangeerror) break; System.out.println("B"); Slide 17 of 22

30 User-defined loops BGGA CICE FCM An example for a user-defined loop. public static for myloop(int times, {=> void body) { int i = 0; while (i < times) { i++; body.invoke(); for myloop(5, {=> System.out.println("A");); Slide 18 of 22 for myloop(5) { System.out.println("A");

31 User-defined loops Behavior of continue and break BGGA CICE FCM This time continue refers to the next iteration of the user-defined control-structure (improved syntax). while (!done) { for myloop(5) { System.out.println("A"); continue; System.out.println("B"); Slide 19 of 22

32 CICE BGGA CICE FCM The second proposal is»concise Instance Creation Expressions: Closures without Complexity«by Bob Lee, Doug Lea and Josh Bloch. This proposal does not define closures it just introduces a more compact syntax for the creation of anonymous classes by omitting a few keywords and identifiers. There are no function-types nor is there any ability to assign closures to a variable or return a closure back to a caller. Slide 20 of 22

33 FCM BGGA CICE FCM The last proposal is»first-class methods: -style closures«by Stephen Colebourne and Stefan Schulz. This proposal allows usage of normal methods of classes and objects and even constructors as closures. For example we can use #(int (int, int)) cl1 = Math#min(int, int); #(int (Object)) cl2 = alist#indexof(object); #(int (List, Object)) cl3 = List#indexOf(Object); #(Integer(int)) ctor = Integer#(int); #(void ()) callback = this#callme(); new Thread(this#callMe()); Slide 21 of 22

34 local variables are not local any more, at least not in the temporal sense this may force verification to model an explicit heap the BGGA-proposal also introduces user-defined control-structures, requiring to capture the targets of return, this, break and continue and thus adding additional complexity the CICE-proposal does not introduce closures the FCM-proposal introduces everything one wants to have regarding closures and nothing beyond Slide 22 of 22

35 local variables are not local any more, at least not in the temporal sense this may force verification to model an explicit heap the BGGA-proposal also introduces user-defined control-structures, requiring to capture the targets of return, this, break and continue and thus adding additional complexity the CICE-proposal does not introduce closures the FCM-proposal introduces everything one wants to have regarding closures and nothing beyond Slide 22 of 22

36 local variables are not local any more, at least not in the temporal sense this may force verification to model an explicit heap the BGGA-proposal also introduces user-defined control-structures, requiring to capture the targets of return, this, break and continue and thus adding additional complexity the CICE-proposal does not introduce closures the FCM-proposal introduces everything one wants to have regarding closures and nothing beyond Slide 22 of 22

37 local variables are not local any more, at least not in the temporal sense this may force verification to model an explicit heap the BGGA-proposal also introduces user-defined control-structures, requiring to capture the targets of return, this, break and continue and thus adding additional complexity the CICE-proposal does not introduce closures the FCM-proposal introduces everything one wants to have regarding closures and nothing beyond Slide 22 of 22

38 local variables are not local any more, at least not in the temporal sense this may force verification to model an explicit heap the BGGA-proposal also introduces user-defined control-structures, requiring to capture the targets of return, this, break and continue and thus adding additional complexity the CICE-proposal does not introduce closures the FCM-proposal introduces everything one wants to have regarding closures and nothing beyond Slide 22 of 22

Closures in Java. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and

Closures in Java. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and License for use and distribution This material is available for non-commercial use and can

More information

JavaScript: Sort of a Big Deal,

JavaScript: Sort of a Big Deal, : Sort of a Big Deal, But Sort of Quirky... March 20, 2017 Lisp in C s Clothing (Crockford, 2001) Dynamically Typed: no static type annotations or type checks. C-Like Syntax: curly-braces, for, semicolons,

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

COMP6700/2140 Methods

COMP6700/2140 Methods COMP6700/2140 Methods Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU 9 March 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Methods 9 March 2017 1 / 19 Methods

More information

Java TM Introduction. Renaud Florquin Isabelle Leclercq. FloConsult SPRL.

Java TM Introduction. Renaud Florquin Isabelle Leclercq. FloConsult SPRL. Java TM Introduction Renaud Florquin Isabelle Leclercq FloConsult SPRL http://www.floconsult.be mailto:info@floconsult.be Java Technical Virtues Write once, run anywhere Get started quickly Write less

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

References and Mutable Data Structures

References and Mutable Data Structures References and Mutable Data Structures Principles of Programming Languages CSE 307 1 Syntax 2 Semantics 3 Version: 1.4 16:44:20 2012/11/29 Compiled at 09:37 on 2018/11/13 Programming Languages References

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Asynchronous Functions in C#

Asynchronous Functions in C# Asynchronous Functions in C# Asynchronous operations are methods and other function members that may have most of their execution take place after they return. In.NET the recommended pattern for asynchronous

More information

Operational Semantics. One-Slide Summary. Lecture Outline

Operational Semantics. One-Slide Summary. Lecture Outline Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:

More information

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions CSE1720 Click to edit Master Week text 01, styles Lecture 02 Second level Third level Fourth level Fifth level Winter 2015! Thursday, Jan 8, 2015 1 Objectives for this class meeting 1. Conduct review of

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to define and invoke void and return java methods JAVA

More information

COMP6700/2140 Code as Data

COMP6700/2140 Code as Data COMP6700/2140 Code as Data Alexei B Khorev Research School of Computer Science, ANU March 2017 Alexei B Khorev (RSCS, ANU) COMP6700/2140 Code as Data March 2017 1 / 19 Topics 1 What does treating code

More information

Control Abstraction. Hwansoo Han

Control Abstraction. Hwansoo Han Control Abstraction Hwansoo Han Review of Static Allocation Static allocation strategies Code Global variables Own variables (live within an encapsulation - static in C) Explicit constants (including strings,

More information

CMSC330. Objects, Functional Programming, and lambda calculus

CMSC330. Objects, Functional Programming, and lambda calculus CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed

More information

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors Outline Overview history and advantage how to: program, compile and execute 8 data types 3 types of errors Control statements Selection and repetition statements Classes and methods methods... 2 Oak A

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Purpose of Review. Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures

Purpose of Review. Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures C++ Review 1 Purpose of Review Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures 2 Class The Class defines the data structure

More information

JavaScript for C# Programmers Kevin

JavaScript for C# Programmers Kevin JavaScript for C# Programmers Kevin Jones kevin@rocksolidknowledge.com @kevinrjones http://www.github.com/kevinrjones Agenda Types Basic Syntax Objects Functions 2 Basics 'C' like language braces brackets

More information

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode STUDENT OUTLINE Lesson 8: Structured Programming, Control Structures, if- Statements, Pseudocode INTRODUCTION: This lesson is the first of four covering the standard control structures of a high-level

More information

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

Type Conversion. and. Statements

Type Conversion. and. Statements and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose

More information

The Java Programming Language

The Java Programming Language The Java Programming Language Slide by John Mitchell (http://www.stanford.edu/class/cs242/slides/) Outline Language Overview History and design goals Classes and Inheritance Object features Encapsulation

More information

4. Java language basics: Function. Minhaeng Lee

4. Java language basics: Function. Minhaeng Lee 4. Java language basics: Function Minhaeng Lee Review : loop Program print from 20 to 10 (reverse order) While/for Program print from 1, 3, 5, 7.. 21 (two interval) Make a condition that make true only

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

More information

Vector and Free Store (Pointers and Memory Allocation)

Vector and Free Store (Pointers and Memory Allocation) DM560 Introduction to Programming in C++ Vector and Free Store (Pointers and Memory Allocation) Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark [Based on slides

More information

Stream Computing using Brook+

Stream Computing using Brook+ Stream Computing using Brook+ School of Electrical Engineering and Computer Science University of Central Florida Slides courtesy of P. Bhaniramka Outline Overview of Brook+ Brook+ Software Architecture

More information

Java Programming Tutorial 1

Java Programming Tutorial 1 Java Programming Tutorial 1 Every programming language has two defining characteristics: Syntax Semantics Programming Writing code with good style also provides the following benefits: It improves the

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far.

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far. Lecture Outline Operational Semantics of Cool COOL operational semantics Motivation Adapted from Lectures by Profs. Alex Aiken and George Necula (UCB) Notation The rules CS781(Prasad) L24CG 1 CS781(Prasad)

More information

内存管理. Memory management

内存管理. Memory management 内存管理 Memory management Review: Constructors Method that is called when an instance is created class Integer { public: int val; Integer() { val = 0; cout

More information

Principles of Software Construction: Concurrency, Part 2

Principles of Software Construction: Concurrency, Part 2 Principles of Software Construction: Concurrency, Part 2 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 5a due now Homework 5 framework goals: Functionally correct Well documented

More information

Goal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search

Goal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search Goal Generic Programming and Inner classes First version of linear search Input was array of int More generic version of linear search Input was array of Comparable Can we write a still more generic version

More information

Operational Semantics of Cool

Operational Semantics of Cool Operational Semantics of Cool Key Concepts semantics: the meaning of a program, what does program do? how the code is executed? operational semantics: high level code generation steps of calculating values

More information

Binghamton University. CS-140 Fall Functional Java

Binghamton University. CS-140 Fall Functional Java Functional Java 1 First Class Data We have learned how to manipulate data with programs We can pass data to methods via arguments We can return data from methods via return types We can encapsulate data

More information

CSCE 156 Computer Science II

CSCE 156 Computer Science II CSCE 156 Computer Science II Lab 04 - Classes & Constructors Dr. Chris Bourke Prior to Lab 1. Review this laboratory handout prior to lab. 2. Read Object Creation tutorial: http://download.oracle.com/javase/tutorial/java/javaoo/objectcreation.

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 2: Objects http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Recap 2 Primitive Types in Java Functions/Procedures

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

Test the Byte Class 1 / 17

Test the Byte Class 1 / 17 Test the Byte Class In Lab 1 and Quiz 1 we tested the class Byte by means of JUnit test case ByteTest. If we run the JUnit test case ByteTest and all tests pass, can we conclude that the class Byte correctly

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within

More information

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Using pointers Pointers are polymorphic Pointer this Using const with pointers Stack and Heap Memory leaks and dangling pointers

More information

IEEE Floating-Point Representation 1

IEEE Floating-Point Representation 1 IEEE Floating-Point Representation 1 x = ( 1) s M 2 E The sign s determines whether the number is negative (s = 1) or positive (s = 0). The significand M is a fractional binary number that ranges either

More information

Roll Number. Common to II Year B.E.CSE & EIE INTERNAL ASSESSMENT TEST - I. Credit 3 R-2017

Roll Number. Common to II Year B.E.CSE & EIE INTERNAL ASSESSMENT TEST - I. Credit 3 R-2017 Roll Number ERODE SENGTHAR ENGINEERING COLLEGE PERDURI, ERODE 638 057 (Accredited by NBA, Accredited by NAAC with A grade, Accredited by IE (I), Kolkotta, Permanently affiliated to Anna University, Chennai

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26, SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation

More information

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional!

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional! CS 498RK FALL 2017 JAVASCRIPT Fashionable and Functional! JAVASCRIPT popular scripting language on the Web, supported by browsers separate scripting from structure (HTML) and presentation (CSS) client-

More information

Procedural Abstraction

Procedural Abstraction Procedural Abstraction Comp-303 : Programming Techniques Lecture 5 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 5 Comp 303 : Programming Techniques Page 1

More information

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

More information

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION Instructors: Crista Lopes Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad Maybe

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

Lesson 36: for() Loops (W11D1)

Lesson 36: for() Loops (W11D1) Lesson 36: for() Loops (W11D1) Balboa High School Michael Ferraro October 26, 2015 1 / 27 Do Now Create a new project: Lesson36 Write class FirstForLoop: Include a main() method: public static void main(string[]

More information

SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE

SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE 1 SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ Java Programming Language Java Introduced in 1995 Object-oriented programming

More information

Pointers. A pointer value is the address of the first byte of the pointed object in the memory. A pointer does not know how many bytes it points to.

Pointers. A pointer value is the address of the first byte of the pointed object in the memory. A pointer does not know how many bytes it points to. Pointers A pointer is a memory address of an object of a specified type, or it is a variable which keeps such an address. Pointer properties: P (pointer) 12316 12316 (address) Typed object A pointer value

More information

// the current object. functioninvocation expression. identifier (expressionlist ) // call of an inner function

// the current object. functioninvocation expression. identifier (expressionlist ) // call of an inner function SFU CMPT 379 Compilers Spring 2015 Assignment 4 Assignment due Thursday, April 9, by 11:59pm. For this assignment, you are to expand your Bunting-3 compiler from assignment 3 to handle Bunting-4. Project

More information

C++ Objects Overloading Other C++ Peter Kristensen

C++ Objects Overloading Other C++ Peter Kristensen Peter Kristensen 2012-12-03 Peter Kristensen Outline 1 What s this thing anyway 2 3 Functions Operators 4 Templates STL A better C 11 Peter Kristensen Overview What s this thing anyway 1 What s this thing

More information

CS1150 Principles of Computer Science Methods

CS1150 Principles of Computer Science Methods CS1150 Principles of Computer Science Methods Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Opening Problem Find the sum of integers from 1 to

More information

Java 8 Programming for OO Experienced Developers

Java 8 Programming for OO Experienced Developers www.peaklearningllc.com Java 8 Programming for OO Experienced Developers (5 Days) This course is geared for developers who have prior working knowledge of object-oriented programming languages such as

More information

INF 102 CONCEPTS OF PROG. LANGS FUNCTIONAL COMPOSITION. Instructors: James Jones Copyright Instructors.

INF 102 CONCEPTS OF PROG. LANGS FUNCTIONAL COMPOSITION. Instructors: James Jones Copyright Instructors. INF 102 CONCEPTS OF PROG. LANGS FUNCTIONAL COMPOSITION Instructors: James Jones Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

Konzepte von Programmiersprachen

Konzepte von Programmiersprachen Konzepte von Programmiersprachen Chapter 5: Continuation-Passing Interpreters Stefan Wehr Universität Freiburg 8. Juni 2009 Konzepte von Programmiersprachen 1 / 43 Motivation Continuations: abstraction

More information

EECS 1001 and EECS 1030M, lab 01 conflict

EECS 1001 and EECS 1030M, lab 01 conflict EECS 1001 and EECS 1030M, lab 01 conflict Those students who are taking EECS 1001 and who are enrolled in lab 01 of EECS 1030M should switch to lab 02. If you need my help with switching lab sections,

More information

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309 A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48

More information

Implicit Evaluation of auto Variables and Arguments

Implicit Evaluation of auto Variables and Arguments Implicit Evaluation of auto Variables and Arguments Document number: N4035 (update of N3748) Authors: Joël Falcou University Paris XI, LRI Peter Gottschling SimuNova Herb Sutter Microsoft Date: 2013-08-30

More information

Data Types. 1 You cannot change the type of the variable after declaration. Zheng-Liang Lu Java Programming 52 / 87

Data Types. 1 You cannot change the type of the variable after declaration. Zheng-Liang Lu Java Programming 52 / 87 Data Types Java is a strongly-typed 1 programming language. Every variable has a type. Also, every (mathematical) expression has a type. There are two categories of data types: primitive data types, and

More information

Lecture Topics. Administrivia

Lecture Topics. Administrivia ECE498SL Lec. Notes L8PA Lecture Topics overloading pitfalls of overloading & conversions matching an overloaded call miscellany new & delete variable declarations extensibility: philosophy vs. reality

More information

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class. 1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity

More information

Goal of lecture. Object-oriented Programming. Context of discussion. Message of lecture

Goal of lecture. Object-oriented Programming. Context of discussion. Message of lecture Goal of lecture Object-oriented Programming Understand inadequacies of class languages like Ur- Java Extend Ur-Java so it becomes an object-oriented language Implementation in SaM heap allocation of objects

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far Lecture Outline Operational Semantics of Cool Lecture 13 COOL operational semantics Motivation Notation The rules Prof. Aiken CS 143 Lecture 13 1 Prof. Aiken CS 143 Lecture 13 2 Motivation We must specify

More information

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

false, import, new 1 class Lecture2 { 2 3 Data types, Variables, and Operators 4 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 45

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays Methods 3 A method: groups a sequence of statement takes input, performs actions, and

More information

CHAPTER 4 FUNCTIONS. 4.1 Introduction

CHAPTER 4 FUNCTIONS. 4.1 Introduction CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main

More information

Course Hours

Course Hours Programming the.net Framework 4.0/4.5 with C# 5.0 Course 70240 40 Hours Microsoft's.NET Framework presents developers with unprecedented opportunities. From 'geoscalable' web applications to desktop and

More information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ CALLING & DEFINING FUNCTIONS 2 Functions and

More information

Objectives. Introduce static keyword examine syntax describe common uses

Objectives. Introduce static keyword examine syntax describe common uses Static Objectives Introduce static keyword examine syntax describe common uses 2 Static Static represents something which is part of a type rather than part of an object Two uses of static field method

More information

Announcements. Scope, Function Calls and Storage Management. Block Structured Languages. Topics. Examples. Simplified Machine Model.

Announcements. Scope, Function Calls and Storage Management. Block Structured Languages. Topics. Examples. Simplified Machine Model. CS 242 2007 Scope, Function Calls and Storage Management John Mitchell Announcements Homework Returned in class Wed; afterwards in 4 th Floor Gates Cabinet SCPD students: attach routing slip, will be returned

More information

The Java Memory Model

The Java Memory Model The Java Memory Model What is it and why would I want one? Jörg Domaschka. ART Group, Institute for Distributed Systems Ulm University, Germany December 14, 2009 public class WhatDoIPrint{ static int x

More information

TYPES, VALUES AND DECLARATIONS

TYPES, VALUES AND DECLARATIONS COSC 2P90 TYPES, VALUES AND DECLARATIONS (c) S. Thompson, M. Winters 1 Names, References, Values & Types data items have a value and a type type determines set of operations variables Have an identifier

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Principles of Computer Science

Principles of Computer Science Principles of Computer Science Lecture 4 Dr. Horia V. Corcalciuc Horia Hulubei National Institute for R&D in Physics and Nuclear Engineering (IFIN-HH) February 10, 2016 Pointers: Assignment Pointer Assignment

More information

Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B

Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has

More information

Lecture 04 FUNCTIONS AND ARRAYS

Lecture 04 FUNCTIONS AND ARRAYS Lecture 04 FUNCTIONS AND ARRAYS 1 Motivations Divide hug tasks to blocks: divide programs up into sets of cooperating functions. Define new functions with function calls and parameter passing. Use functions

More information

Class object initialization block destructor Class object

Class object initialization block destructor Class object In this segment, I will review the Java statements and primitives that relate explicitly to Object Oriented Programming. I need to re-enforce Java s commitment to OOP. Unlike C++, there is no way to build

More information

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17 CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays 1 Methods : Method Declaration: Header 3 A method declaration begins with a method header

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University Processes Design, Spring 2011 Department of Computer Science Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode instruction Execute instruction CPU

More information

CSE 431S Final Review. Washington University Spring 2013

CSE 431S Final Review. Washington University Spring 2013 CSE 431S Final Review Washington University Spring 2013 What You Should Know The six stages of a compiler and what each stage does. The input to and output of each compilation stage (especially the back-end).

More information

The Compositional C++ Language. Denition. Abstract. This document gives a concise denition of the syntax and semantics

The Compositional C++ Language. Denition. Abstract. This document gives a concise denition of the syntax and semantics The Compositional C++ Language Denition Peter Carlin Mani Chandy Carl Kesselman March 12, 1993 Revision 0.95 3/12/93, Comments welcome. Abstract This document gives a concise denition of the syntax and

More information

Team: The Cimple Programming Language

Team: The Cimple Programming Language Team: Shankara Pailoor (sp3485) Panchampreet Kaur (pk2506) Graham Barab (gmb2154) The Cimple Programming Language We hope to build a statically typed language based off C with features that enable the

More information

OOP: Key Concepts 09/28/2001 1

OOP: Key Concepts 09/28/2001 1 OOP: Key Concepts Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring 09/28/2001 1 Overview of Part

More information

CSE 341, Autumn 2015, Ruby Introduction Summary

CSE 341, Autumn 2015, Ruby Introduction Summary CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 35 November 29, 2017 Swing II: Building GUIs Inner Classes Chapter 29 Announcements Game Project Complete Code Due: December 11 th NO LATE SUBMISSIONS

More information

Implementing Subprograms

Implementing Subprograms Implementing Subprograms 1 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables Nested Subprograms Blocks Implementing

More information

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Utilities (Part 2) Implementing static features

Utilities (Part 2) Implementing static features Utilities (Part 2) Implementing static features 1 Goals for Today learn about preventing class instantiation learn about methods static methods method header method signature method return type method

More information

Computer Programming, I. Laboratory Manual. Experiment #7. Methods

Computer Programming, I. Laboratory Manual. Experiment #7. Methods Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #7

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Data Structures using OOP C++ Lecture 3

Data Structures using OOP C++ Lecture 3 References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.

More information

CSCE 120: Learning To Code

CSCE 120: Learning To Code CSCE 120: Learning To Code Module 9.0: Organizing Code I Introduction to Functions This module is designed to get you started working with functions which allow you to organize code into reusable units

More information

COEN244: Class & function templates

COEN244: Class & function templates COEN244: Class & function templates Aishy Amer Electrical & Computer Engineering Templates Function Templates Class Templates Outline Templates and inheritance Introduction to C++ Standard Template Library

More information