1 CS 403 - Programming Languages Class 15 October 17, 2000.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

ISBN Chapter 9 Subprograms. Copyright © 2007 Addison-Wesley. All rights reserved.1-2 Chapter 9 Topics Introduction Fundamentals of Subprograms.
Chapter 7: User-Defined Functions II
Chapter 9 Subprograms.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
(1) ICS 313: Programming Language Theory Chapter 10: Implementing Subprograms.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
ISBN Chapter 10 Implementing Subprograms.
ISBN Chapter 9 Subprograms. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.9-2 Chapter 9 Topics Introduction Fundamentals.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
Chapter 9: Subprogram Control
1 CSCI 360 Survey Of Programming Languages 9 – Implementing Subprograms Spring, 2008 Doug L Hoffman, PhD.
Abstract Data Types and Encapsulation Concepts
ISBN Chapter 9 Subprograms and Functions –Design Issues –Local Referencing Environments –Parameter-Passing Methods –Parameters that are Subprogram.
Scope.
© 2003 G. Drew Kessler and William M. Pottenger1 Subroutines (Part 1) CSE 262, Spring 2003.
1 Subprograms Fundamentals of subprograms Design issues for subprograms –Parameter-passing methods –Type checking of parameters –Static or dynamic storage.
Chapter Nine: Subprograms Lesson 09. What are they  Modularized code  Might return a value  Functions  Or not  Procedures  Subroutines  In object.
1 CS Programming Languages Class 07 September 14, 2000.
Names Variables Type Checking Strong Typing Type Compatibility 1.
Chapter 9 Subprograms Fundamentals of Subprograms
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
April 23, ICE 1341 – Programming Languages (Lecture #16) In-Young Ko Programming Languages (ICE 1341) Lecture #16 Programming Languages (ICE 1341)
1 Chapter 9 © 2002 by Addison Wesley Longman, Inc. 9.2 Fundamentals of Subprograms - General characteristics of subprograms: 1. A subprogram has a single.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 8 Fundamental Characteristics of Subprograms 1. A subprogram has a single entry point 2. The.
Basic Semantics Associating meaning with language entities.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
Week 7 Subprograms. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Chapter 9 Topics Introduction Fundamentals of Subprograms Design Issues for.
1 CS Programming Languages Class 11 September 26, 2000.
Programming Languages and Paradigms Imperative Programming.
1 Subprograms In Text: Chapter 8. 2 Chapter 8: Subprograms Outline Definitions Referencing environments Parameter passing modes and mechanisms Independent.
Chapter 9 Subprograms. 2 Fundamentals of Subprograms Each subprogram has a single entry point The calling program is suspended during execution of the.
Implementing Subprograms What actions must take place when subprograms are called and when they terminate? –calling a subprogram has several associated.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan.
1 CS Programming Languages Class 09 September 21, 2000.
Chapter 9 Subprograms. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Chapter 9 Topics Introduction Fundamentals of Subprograms Design Issues.
ISBN Chapter 9 Subprograms. Corrected and improved by Assoc. Prof. Zeki Bayram, EMU, North Cyprus. Original Copyright © 2007 Addison-Wesley.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
10-1 Chapter 10: Implementing Subprograms The General Semantics of Calls and Returns Implementing “Simple” Subprograms Implementing Subprograms with Stack-Dynamic.
ISBN Chapter 10 Implementing Subprograms.
Implementing Subprograms
1 CS Programming Languages Class 10 September 26, 2000.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
ISBN Chapter 10 Implementing Subprograms.
ISBN Chapter 9 Subprograms. Copyright © 2007 Addison-Wesley. All rights reserved.1-2 Chapter 9 Topics Introduction Fundamentals of Subprograms.
Chapter 9 Subprograms. Chapter 9 Topics Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments Parameter-Passing.
Implementing Subprograms
Chapter 9 Subprograms.
Chapter 9 Subprograms.
Implementing Subprograms
Names and Attributes Names are a key programming language feature
CS 326 Programming Languages, Concepts and Implementation
CSCI 3370: Principles of Programming Languages Chapter 9 Subprograms
Chapter 10: Implementing Subprograms Sangho Ha
Implementing Subprograms
Scope, Visibility, and Lifetime
Chapter 9 Subprograms.
Subprograms In Text: Chapter 9.
Subject : T0152 – Programming Language Concept
Chapter 9 Subprograms Subprograms are the fundamental building blocks of programs and are therefore the most important concepts in programming language.
Implementing Subprograms
Presentation transcript:

1 CS Programming Languages Class 15 October 17, 2000

CS 403, Class 15 Slide # 2 Today’s Agenda Finish Chapter 8 Start Chapter 9 Assignment: Read chapter 9 for next Tuesday Prepare for Exam Thursday. Announcement: Exam is Oct 19. Exam will cover chapters 1-8.

CS 403, Class 15 Slide # 3 Project 1 Writing Assignment Compare string handling in C++ and Ada. Remember: This is part of the W designation for this course, so you will be graded on writing style as well as content! Due October 26 th. Assignment on web site.

CS 403, Class 15 Slide # 4 Reminder Advising period: Oct Please update your “CS Students” links & website. Update your links at Build your own website on the CS server using FrontPage. Directions are at

CS 403, Class 15 Slide # 5 ACM Meeting Bret McKee of ExxonMobil Career Development / Management Pizza & a movie to follow 5:30 today Semester dues: $5

CS 403, Class 15 Slide # 6 Unpaid Political Announcement Three weeks till Election Day… Vote!

CS 403, Class 15 Slide # 7 Chapter 8: Already Covered… Basic Subprogram terms Actual/Formal Parameters Local environment Parameter passing modes & implementations Type checking parameters Multidimensional Arrays as Parameters

CS 403, Class 15 Slide # 8 Chapter 8: Already Covered… Design Considerations for Parameter Passing Parameters that are Subprogram Names Overloaded Subprograms Generic Subprograms Independent compilation vs. Separate compilation

CS 403, Class 15 Slide # 9 Functions Design Issues: 1.Are side effects allowed? a)Two-way parameters (Ada does not allow) b)Nonlocal reference (all allow) 2.What types of return values are allowed?

CS 403, Class 15 Slide # 10 Functions Language Examples (for possible return types): 1.FORTRAN, Pascal, Modula-2 - only simple types 2.C - any type except functions and arrays 3.Ada - any type (but subprograms are not types) 4.C++ and Java - like C, but also allow classes to be returned

CS 403, Class 15 Slide # 11 Accessing Nonlocal Environments Def: The nonlocal variables of a subprogram are those that are visible but not declared in the subprogram. Def: Global variables are those that may be visible in all of the subprograms of a program.

CS 403, Class 15 Slide # 12 Accessing Nonlocal Environments Methods: 1. FORTRAN COMMON block The only way in pre-90 FORTRANs to access nonlocal variables Can be used to share data or share storage 2. Static scoping - discussed in Chapter 4 3. Dynamic Scope - discussed in Chapter 4

CS 403, Class 15 Slide # 13 Accessing Nonlocal Environments Methods: 4. External declarations - C Subprograms are not nested Globals are created by external declarations (they are simply defined outside any function) Access is by either implicit or explicit declaration Declarations (not definitions) give types to externally defined variables (and say they are defined elsewhere) 5. External modules - Ada and Modula-2 More about these later (Chapter 10)

CS 403, Class 15 Slide # 14 User-Defined Overloaded Operators Nearly all programming languages have overloaded operators Users can further overload operators in C++ and Ada (Not carried over into Java) Example (Ada) (assume VECTOR_TYPE has been defined to be an array type with INTEGER elements) – next slide-

CS 403, Class 15 Slide # 15 User-Defined Overloaded Operators function "*"(A, B : in VECTOR_TYPE) return INTEGER is SUM : INTEGER := 0; begin for INDEX in A'range loop SUM := SUM + A(INDEX) * B(INDEX); end loop; return SUM; end "*"; When are user-defined overloaded operators good? When are they bad?

CS 403, Class 15 Slide # 16 Coroutines A coroutine is a subprogram that has multiple entries and controls them itself Also called symmetric control A coroutine call is named a resume The first resume of a coroutine is to its beginning, but subsequent calls enter at the point just after the last executed statement in the coroutine Typically, coroutines repeatedly resume each other, possibly forever Coroutines provide quasi-concurrent execution of program units (the coroutines) Their execution is interleaved, but not overlapped

CS 403, Class 15 Slide # 17 End of Chapter 8! End of material on exam Thursday. Any questions on any material: chapters 1 - 8? Expect several ‘short essay’ questions. Expect some sections of code with questions based on the code. Sample exam on the web page.

CS 403, Class 15 Slide # 18 Exam “Review” One good way to study: meet with 2-3 other students and review the material. Ask yourself: What are the important questions here? Post your questions to the class discussion group, and read what other students have posted. I’ll award two bonus points on the exam to each member of a group of 2-4 that posts 3 good questions each for two chapters by 5PM Wednesday (6 questions total). I’ll award 1 bonus point for 3 worked (correctly!) questions from the posted exam, posted to the discussion group.