Parameter Passing in Pascal
|
|
- Sheila Jodie Paul
- 7 years ago
- Views:
Transcription
1 Parameter Passing in Pascal Mordechai Ben-Ari Department of Science Teaching Weizmann Institute of Science Rehovot Israel Abstract This paper claims that reference parameters as such should not be taught in introductory courses on programming that use Pascal or C++. Rather, formal reference parameters should be taught as renamings of the actual parameters. Furthermore, the choice between copy and reference parameters should be based on intended use, not on implementation. We show that reference parameters are not as efficient as is naively believed, so there is no impediment to the proposed criterion. 1 Introduction My group develops a two-year course called Fundamentals of Computer Science for high-school students (10th and 11th grade). Teachers of the course uniformly report that many students have difficultly forming a mental model of a computer; for example, students often struggle with the semantics of the read statement, because it is not clear who is reading what from where! Since pointers are not taught within this course, a question we had to deal with was how to teach reference parameters without explicitly expanding the mental model of the computer to include variables containing machine addresses. The question is important since modern introductory computer science courses emphasize algorithms, not machines; one ought to be able to develop and implement a sort algorithm without understanding the underlying machine. This article reports on techniques developed to teach parameters that employ intended use rather than implementation of the parameter passing mechanism to guide the presentation. The techniques will be especially useful to teachers of non-majors who cannot be expected to develop a full model of a computer in the short time they are exposed to the subject. The discussion is given for the Pascal language; it is directly applicable to C++ which uses the same two parameter passing modes. C, of course, requires the early introduction of pointers, and this is a major reason why the language is difficult to teach. Ada s parameter passing modes are specified in terms of use rather than implementation and were the inspiration for this work. Languages based on reference semantics (Eiffel, 1
2 Smalltalk, Java) do not need reference parameters since any actual parameter can be modified and any object returned. The paper is organized as follows. We review the concepts or value and reference parameters in Section 2, and then in Section 3 discuss parameter modes in Ada. Section 4 shows how to transfer the Ada concepts to Pascal and Section 5 discusses the immediate objection that is always raised: the alleged inefficiency of value parameters. In Section 6 we present our method for teaching parameters as renamings. 2 Value and reference parameters Pascal has two modes for passing parameters to a procedure or function: value and reference. The former is the default and the latter is indicated by the use of the keyword var in front of the formal parameter. In value mode the actual parameter can be an expression and the formal parameter contains a copy of the value of the expression. Any assignment to the formal parameter does not affect the actual parameter, even if the actual parameter is a variable. In reference mode the actual parameter must be a variable and the formal parameter contains a pointer to that variable. Assignment to the formal parameter is an assignment to the actual parameter. Value parameters are, of course, easy to teach because they are equivalent to initialized local variables. However, reference parameters are correctly explained in terms of pointers and address; for example [2], p. 241: The compiler stores the memory address of the actual parameter that corresponds to each variable parameter in the procedure data area. This is an advanced concept best deferred as long as possible. The problem with the definition of Pascal is that it is given in terms of implementation, while most programmers (and certainly beginning students) need only be aware of the rules concerning the intended use of the parameters. 3 Parameter modes in Ada Parameter passing in Ada is defined by intended use and is thus easier to teach than the Pascal definition. Consider the following procedure declarations: procedure Quadratic( A, B, C: in Float; Root1, Root2: out Float); procedure Sort(V: in out Vector); Parameters of mode in can only be read, parameters of mode out can only be written, and parameters of mode in out can be both read and written. This clearly corresponds with the intended interpretation of the parameters in the examples: a procedure to solve a quadratic equation needs to read three coefficients and to write back two roots; a sort procedure is invoked in order to read and modify the actual parameter. 2
3 From the point of view of software engineering (reliability of interfaces between team members), in is superior to out which in turn is superior to in out. Specifying a mode of higher risk is acceptable only if the functionality it offers is required. The following paragraph summarizes the parameter passing mechanism actually used in Ada, and may be skipped without loss of continuity. Even though the above specification is sufficient to program in Ada, the standard goes on to specify the required implementation ([1], 6.2). Scalar parameters such as numbers and pointers must be implemented by copy: copy-in upon procedure entry for in and in out modes, and copy-out at the end of the procedure for out and in out modes. Structures such as tasks (concurrent processes) that have no meaning as values must be passed by reference. However, a compiler may use either copy or reference to implementation parameter passing for arrays and records. It is possible to write clever programs that produce different results under different implementations; such programs are simply not portable. 4 What should we do in Pascal? Beginning students should be taught that reliability is one of the most important criteria in choosing programming structures. Thus call by value should always the preferred mode for parameter passing in Pascal, unless the functionality of reference is required. For example, the declaration of a search procedure would be: procedure Search( V: Vector; Key: Float; var Found: Integer); where only the returned index is a var parameter. The vector itself is passed by value since it is not modified. A sort procedure would, of course, pass the vector by reference: procedure Sort(var V: Vector); The implicit mapping from Ada modes to Pascal modes is that in parameters are equivalent to call by value, and out and in out parameters are equivalent to call by reference. It is also a good idea to carry the equivalence further and to refrain from modifying value parameters, as this can only confuse a student. C++ is similar to Pascal in that an unadorned parameter is passed by value, while the ampersand sign is used to indicate reference parameters. In Pascal, we use the term var-parameter to avoid the explicit word reference ; similarly, in C++, one could use the term ampersand-parameter. Furthermore, C++ supports declaration of parameters as const which should be appended to all value parameters to emphasize the one-way passing of data from the caller to the function. Unfortunately, C++ cannot pass an array by value. Thus you should prefer a (safe) implementation of an array type within a class to predefined arrays. 5 Efficiency! One often hears that the most common cause of bugs is clever coding aimed at writing efficient programs. Modern software engineering practice dictates that: (i) efficiency 3
4 Next statement A B Temp Output Temp := A 3 4? A := B B := Temp Figure 1: Tracking table be only a secondary concern to correctness, (ii) efficiency improvement be undertaken only at as a result of actual measurements (and only at places indicated by the measurement), and (iii) efficiency is best served by choosing better algorithms and not by tinkering with the program code. Conventional wisdom holds that arrays should be passed as var parameters rather than as value parameters because var parameters are more efficient : you do not have to copy the entire array. In an attempt to verify this claim, I wrote a program that passed a 25,000 byte array as a parameter to a procedure that computed the sum of the elements. The procedure was repeatedly called in a loop to ensure that the program ran long enough for easy measurement. I could not measure any run-time difference between value and reference passing of the parameter! Contrary to conventional wisdom, it can be more efficient to use value parameters. The reason is that copying an array is typically implemented by a single efficient block-copy instruction. Most procedures, however, will repeatedly access the formal parameter: think of an elementary sort procedure which will access each of n elements approximately n times. Access to a value parameter in the activation record of the procedure is much more efficient than an access to a reference parameter. The latter requires an extra instruction for the indirect reference, and this can overwhelm any savings obtained by passing a reference as opposed to copying a value. Thus it seems that the only valid efficiency-related reason for using reference parameters is to save memory on the stack. However, depth of nesting of procedures is usually very small, even in recursive procedures (since they are typically written to implement algorithms that traverse data structures of depth log n). Increasing the stack by 10K or so, should cover the additional memory required to pass most, if not all, readonly parameters by value. Efficiency concerns are only relevant when the parameter size is very large, that is, many thousands of bytes. Student programs obviously do not meet this criterion. 6 Tracking tables In our course, tracking tables are used to model the progress of a computation. Each line of a table contains the instruction counter the next instruction to be executed, and the current values of all the variables. For example, the following table in Figure 1 shows the computation of three assignment statements, assuming that A and B have been initialized to 3 and 4, respectively, and Temp is not initialized. 4
5 The extension to value parameters is immediate: additional columns are added to the table. The columns are labeled with the names of the formal parameters and initialized with the values of the actual parameters. We demonstrate the extension on the following program which swaps the values of its input (incorrectly since the parameters are value parameters): 5
6 Next statement X Y Output readln(x,y)?? Swap(X,Y) 3 4 A B Temp Temp := A ? A := B B := Temp writeln(x,y) Figure 2: Tracking table with value parameters program P; var X, Y: Integer; procedure Swap(A, B: Integer); var Temp: begin Temp := A; A := B; B := Temp; end; begin readln(x, Y); Swap(X, Y); writeln(x, Y) end. The tracking table is shown in Figure 2. Note how the value parameters and local variables are created upon entrance to the procedure and destroyed upon exit. So far, so good: the table clearly demonstrates the concept of stack allocation without discussing the underlying implementation. To continue the use of these diagrams for reference parameters would require that columns contain arrows to the columns representing the global variables, but this introduces the implementation issues that we wish to avoid. Instead, the columns for the actual parameters are renamed with the names of the actual parameters. The tracking table is shown in Figure 3, assuming that the parameters of Swap are now correctly written as var parameters. Renaming the actual parameters is not only easy to explain and understand, it is also consistent with the actual implementation of reference parameters as seen by the common use of the word alias in this context. To be truly precise, we should say that the formal parameter is an additional name for the actual parameter. In our course, the difference is moot: to encourage good software engineering practice, we do not allow the students to access global variables. 6
7 Next statement X Y Output readln(x,y)?? Swap(X,Y) 3 4 A B Temp Temp := A 3 4? A := B B := Temp X Y writeln(x,y) Conclusion Figure 3: Tracking table with reference parameters Parameter passing is one of the most difficult concepts that a beginning student of programming has to learn. We recommend that the student be taught to choose a parameter passing mode based on the criterion of intended use, and that reference parameters be disguised as renamings. Only as they advance in their studies, should the implementation and efficiency of parameter passing be analyzed. Acknowledgement I would like to thank Orna Lichtenstein for the many discussions we had on this topic. References [1] Intermetrics. Ada 95 Language Reference Manual, ANSI/ISO/IEC 8652:1995. [2] Eliot B. Koffman. Pascal: Problem Solving and Program Design (Fourth Edition). Addison-Wesley, Reading, MA,
Stack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
More informationEfficient Data Structures for Decision Diagrams
Artificial Intelligence Laboratory Efficient Data Structures for Decision Diagrams Master Thesis Nacereddine Ouaret Professor: Supervisors: Boi Faltings Thomas Léauté Radoslaw Szymanek Contents Introduction...
More informationParameter passing in LISP
Parameter passing in LISP The actual parameters in a function call are always expressions, represented as lists structures. LISP provides two main methods of parameter passing: Pass/Call-by-value. The
More information2) Write in detail the issues in the design of code generator.
COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage
More informationSymbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
More informationDatabase Programming with PL/SQL: Learning Objectives
Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs
More informationLab Experience 17. Programming Language Translation
Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly
More informationPseudo code Tutorial and Exercises Teacher s Version
Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy
More informationOrganization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.
Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Names, Bindings, and Scopes A name is a symbolic identifier used
More informationParameter Passing. Parameter Passing. Parameter Passing Modes in Fortran. Parameter Passing Modes in C
Parameter Passing In this set of notes you will learn about: Parameter passing modes Call by Call by reference Call by sharing Call by result Call by /result Call by name Subroutine closures as parameters
More informationlanguage 1 (source) compiler language 2 (target) Figure 1: Compiling a program
CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program
More informationCOMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.
COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms 1 Activation Records activation declaration location Recall that an activation
More informationLecture Notes on Linear Search
Lecture Notes on Linear Search 15-122: Principles of Imperative Computation Frank Pfenning Lecture 5 January 29, 2013 1 Introduction One of the fundamental and recurring problems in computer science is
More informationCOMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012
Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationOpenACC 2.0 and the PGI Accelerator Compilers
OpenACC 2.0 and the PGI Accelerator Compilers Michael Wolfe The Portland Group michael.wolfe@pgroup.com This presentation discusses the additions made to the OpenACC API in Version 2.0. I will also present
More informationPassing Arguments. A comparison among programming languages. Curtis Bright. April 20, 2011
Passing Arguments A comparison among programming languages Curtis Bright April 20, 2011 Abstract This report describes and compares the argument passing styles used in contemporary programming languages,
More informationFriendship and Encapsulation in C++
Friendship and Encapsulation in C++ Adrian P Robson Department of Computing University of Northumbria at Newcastle 23rd October 1995 Abstract There is much confusion and debate about friendship and encapsulation
More informationHow to test and debug an ASP.NET application
Chapter 4 How to test and debug an ASP.NET application 113 4 How to test and debug an ASP.NET application If you ve done much programming, you know that testing and debugging are often the most difficult
More informationPART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
More information16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution
16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more
More informationFigure 1: Graphical example of a mergesort 1.
CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your
More information15-150 Lecture 11: Tail Recursion; Continuations
15-150 Lecture 11: Tail Recursion; Continuations Lecture by Dan Licata February 21, 2011 In this lecture we will discuss space usage: analyzing the memory it takes your program to run tail calls and tail
More informationVB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
More informationManaging Variability in Software Architectures 1 Felix Bachmann*
Managing Variability in Software Architectures Felix Bachmann* Carnegie Bosch Institute Carnegie Mellon University Pittsburgh, Pa 523, USA fb@sei.cmu.edu Len Bass Software Engineering Institute Carnegie
More informationInstruction Set Architecture (ISA)
Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine
More informationCS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
More informationAn Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
More informationLecture 3: Finding integer solutions to systems of linear equations
Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture
More information1 The Java Virtual Machine
1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This
More informationParameter Passing Methods
Parameter Passing Methods Procedural abstraction Parameter passing methods pass by value pass by result pass by value-result pass by reference aliasing pass by name Procedures/functions as arguments 1
More informationChapter 4: Tools of Modern Systems Analysis
Just Enough Structured Analysis Chapter 4: Tools of Modern Systems Analysis Nature has... some sort of arithmetical-geometrical coordinate system, because nature has all kinds of models. What we experience
More informationKeil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
More informationFunctions and Parameter Passing
Chapter 5: Functions and Parameter Passing In this chapter, we examine the difference between function calls in C and C++ and the resulting difference in the way functions are defined in the two languages.
More informationObject-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More informationASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER
ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER Pierre A. von Kaenel Mathematics and Computer Science Department Skidmore College Saratoga Springs, NY 12866 (518) 580-5292 pvonk@skidmore.edu ABSTRACT This paper
More informationAdvanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2
Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of
More informationChapter 5 Instructor's Manual
The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 5 Instructor's Manual Chapter Objectives Chapter 5, A Closer Look at Instruction
More informationCommon Data Structures
Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees
More informationDebugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationRegions in a circle. 7 points 57 regions
Regions in a circle 1 point 1 region points regions 3 points 4 regions 4 points 8 regions 5 points 16 regions The question is, what is the next picture? How many regions will 6 points give? There's an
More informationSYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison
SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89 by Joseph Collison Copyright 2000 by Joseph Collison All rights reserved Reproduction or translation of any part of this work beyond that permitted by Sections
More informationThe C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
More informationCSCI 3136 Principles of Programming Languages
CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University Winter 2013 CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University
More informationPL/SQL Overview. Basic Structure and Syntax of PL/SQL
PL/SQL Overview PL/SQL is Procedural Language extension to SQL. It is loosely based on Ada (a variant of Pascal developed for the US Dept of Defense). PL/SQL was first released in ١٩٩٢ as an optional extension
More informationSelecting a Visualization System
134 Third Program Visualization Workshop 1 Introduction Selecting a Visualization System Sarah Pollack, Mordechai Ben-Ari Department of Science Teaching, Weizmann Institute of Science, Israel moti.ben-ari@weizmann.ac.il
More information1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.
1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated
More informationFormal Languages and Automata Theory - Regular Expressions and Finite Automata -
Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March
More informationPersistent Binary Search Trees
Persistent Binary Search Trees Datastructures, UvA. May 30, 2008 0440949, Andreas van Cranenburgh Abstract A persistent binary tree allows access to all previous versions of the tree. This paper presents
More informationProgramming Languages & Tools
4 Programming Languages & Tools Almost any programming language one is familiar with can be used for computational work (despite the fact that some people believe strongly that their own favorite programming
More informationClass Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction
Class Overview CSE 326: Data Structures Introduction Introduction to many of the basic data structures used in computer software Understand the data structures Analyze the algorithms that use them Know
More informationTrace-Based and Sample-Based Profiling in Rational Application Developer
Trace-Based and Sample-Based Profiling in Rational Application Developer This document is aimed at highlighting the importance of profiling in software development and talks about the profiling tools offered
More information1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier.
Study Group 1 Variables and Types 1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier. 2. What does the byte 00100110 represent? 3. What is the purpose of the declarations
More informationHigh-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
More informationScoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
More informationSequential Data Structures
Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year
More informationGuidance paper - The use of calculators in the teaching and learning of mathematics
Guidance paper - The use of calculators in the teaching and learning of mathematics Background and context In mathematics, the calculator can be an effective teaching and learning resource in the primary
More informationCompiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding
Compiling Object Oriented Languages What is an Object-Oriented Programming Language? Last time Dynamic compilation Today Introduction to compiling object oriented languages What are the issues? Objects
More informationNode-Based Structures Linked Lists: Implementation
Linked Lists: Implementation CS 311 Data Structures and Algorithms Lecture Slides Monday, March 30, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org
More informationHandout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
More informationPL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
More informationStack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.
Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationComputer Programming Lecturer: Dr. Laith Abdullah Mohammed
Algorithm: A step-by-step procedure for solving a problem in a finite amount of time. Algorithms can be represented using Flow Charts. CHARACTERISTICS OF AN ALGORITHM: Computer Programming Lecturer: Dr.
More informationADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science
ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science Program Schedule CTech Computer Science Credits CS101 Computer Science I 3 MATH100 Foundations of Mathematics and
More informationNUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:
APPENDIX D NUMBER SYSTEMS You will learn about the following in this appendix: The four important number systems in computing binary, octal, decimal, and hexadecimal. A number system converter program
More informationNotes on Algorithms, Pseudocode, and Flowcharts
Notes on Algorithms, Pseudocode, and Flowcharts Introduction Do you like hot sauce? Here is an algorithm for how to make a good one: Volcanic Hot Sauce (from: http://recipeland.com/recipe/v/volcanic-hot-sauce-1125)
More informationSection 1.7 22 Continued
Section 1.5 23 A homogeneous equation is always consistent. TRUE - The trivial solution is always a solution. The equation Ax = 0 gives an explicit descriptions of its solution set. FALSE - The equation
More informationrecursion, O(n), linked lists 6/14
recursion, O(n), linked lists 6/14 recursion reducing the amount of data to process and processing a smaller amount of data example: process one item in a list, recursively process the rest of the list
More informationNetBeans Profiler is an
NetBeans Profiler Exploring the NetBeans Profiler From Installation to a Practical Profiling Example* Gregg Sporar* NetBeans Profiler is an optional feature of the NetBeans IDE. It is a powerful tool that
More informationMath Content by Strand 1
Math Content by Strand 1 Number and Operations with Whole Numbers Multiplication and Division Grade 3 In Grade 3, students investigate the properties of multiplication and division, including the inverse
More information13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationMemory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation
Dynamic Storage Allocation CS 44 Operating Systems Fall 5 Presented By Vibha Prasad Memory Allocation Static Allocation (fixed in size) Sometimes we create data structures that are fixed and don t need
More information(Refer Slide Time: 2:03)
Control Engineering Prof. Madan Gopal Department of Electrical Engineering Indian Institute of Technology, Delhi Lecture - 11 Models of Industrial Control Devices and Systems (Contd.) Last time we were
More informationInstruction Set Design
Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,
More informationWhat Is Recursion? Recursion. Binary search example postponed to end of lecture
Recursion Binary search example postponed to end of lecture What Is Recursion? Recursive call A method call in which the method being called is the same as the one making the call Direct recursion Recursion
More informationAC 2007-2027: A PROCESSOR DESIGN PROJECT FOR A FIRST COURSE IN COMPUTER ORGANIZATION
AC 2007-2027: A PROCESSOR DESIGN PROJECT FOR A FIRST COURSE IN COMPUTER ORGANIZATION Michael Black, American University Manoj Franklin, University of Maryland-College Park American Society for Engineering
More informationDjango Assess Managed Nicely Documentation
Django Assess Managed Nicely Documentation Release 0.2.0 Curtis Maloney August 06, 2014 Contents 1 Settings 1 1.1 DAMN_PROCESSORS......................................... 1 1.2 DAMN_MODE_MAP..........................................
More informationQuotes from Object-Oriented Software Construction
Quotes from Object-Oriented Software Construction Bertrand Meyer Prentice-Hall, 1988 Preface, p. xiv We study the object-oriented approach as a set of principles, methods and tools which can be instrumental
More informationOBJECTS-FIRST VS. STRUCTURES-FIRST APPROACHES TO OO PROGRAMMING EDUCATION: AN EMPIRICAL STUDY
page 244 OBJECTS-FIRST VS. STRUCTURES-FIRST APPROACHES TO OO PROGRAMMING EDUCATION: AN EMPIRICAL STUDY Richard A. Johnson, Missouri State University Duane R. Moses, Missouri State University RichardJohnson@MissouriState.edu
More informationOn the (un)suitability of Java to be the first programming language
On the (un)suitability of Java to be the first programming language Mirjana Ivanovic Faculty of Science, Department of Mathematics and Informatics Trg Dositeja Obradovica 4, Novi Sad mira @im.ns.ac.yu
More informationData Structures and Algorithms
Data Structures and Algorithms Computational Complexity Escola Politècnica Superior d Alcoi Universitat Politècnica de València Contents Introduction Resources consumptions: spatial and temporal cost Costs
More informationBinary Search Trees CMPSC 122
Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than
More informationParsing Technology and its role in Legacy Modernization. A Metaware White Paper
Parsing Technology and its role in Legacy Modernization A Metaware White Paper 1 INTRODUCTION In the two last decades there has been an explosion of interest in software tools that can automate key tasks
More informationASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)
ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6) 1 COMPUTER LANGUAGES In order for a computer to be able to execute a program, the program must first be present
More informationInformation Technology Software development GA 1 and 2: Unit 3 Information Technology Software development GA 1 and 2: Unit 4
Information Technology Software development GA 1 and 2: Unit 3 Information Technology Software development GA 1 and 2: Unit 4 UNIT 3 This report is provided for the first year of implementation of this
More informationChapter 8: Bags and Sets
Chapter 8: Bags and Sets In the stack and the queue abstractions, the order that elements are placed into the container is important, because the order elements are removed is related to the order in which
More informationCOMPUTER SCIENCE. Paper 1 (THEORY)
COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------
More informationChapter 5 Functions. Introducing Functions
Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name
More informationSection of DBMS Selection & Evaluation Questionnaire
Section of DBMS Selection & Evaluation Questionnaire Whitemarsh Information Systems Corporation 2008 Althea Lane Bowie, Maryland 20716 Tele: 301-249-1142 Email: mmgorman@wiscorp.com Web: www.wiscorp.com
More informationMemory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example
Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include
More informationLinked Lists: Implementation Sequences in the C++ STL
Linked Lists: Implementation Sequences in the C++ STL continued CS 311 Data Structures and Algorithms Lecture Slides Wednesday, April 1, 2009 Glenn G. Chappell Department of Computer Science University
More informationTopics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
More informationLast Class: OS and Computer Architecture. Last Class: OS and Computer Architecture
Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts
More information9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
More informationTom wants to find two real numbers, a and b, that have a sum of 10 and have a product of 10. He makes this table.
Sum and Product This problem gives you the chance to: use arithmetic and algebra to represent and analyze a mathematical situation solve a quadratic equation by trial and improvement Tom wants to find
More informationProgramming Languages
Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately
More information