Download presentation
Presentation is loading. Please wait.
Published byLetitia Gibbs Modified over 9 years ago
1
1 CS 403 - Programming Languages Class 15 October 17, 2000
2
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.
3
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.
4
CS 403, Class 15 Slide # 4 Reminder Advising period: Oct 16-27 Please update your “CS Students” links & website. Update your links at http://cs.ua.edu/1Students.asp http://cs.ua.edu/1Students.asp Build your own website on the CS server using FrontPage. Directions are at http://cs.ua.edu/9StudentWebSites.shtm http://cs.ua.edu/9StudentWebSites.shtm
5
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
6
CS 403, Class 15 Slide # 6 Unpaid Political Announcement Three weeks till Election Day… Vote!
7
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
8
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
9
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?
10
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
11
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.
12
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
13
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)
14
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-
15
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?
16
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
17
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.
18
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.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.