324-lecture20 - Principles of Programming Languages...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Principles of Programming Languages Principles of Programming Languages Lecture 20 Lecture 20 University of Toronto Wael Aboulsaadat Wael Aboulsaadat wael@cs.toronto.edu wael@cs.toronto.edu http://portal.utoronto.ca/ 1 Components of an Imperative Language Components of an Imperative Language Data types Variables, operators & Expressions Iteration construct University of Toronto Branching construct b Subprogram construct Container construct 2 Subprograms: big picture Subprograms: big picture Sample memory layout A program with 4 sub-programs: A, B, C and D code code runtime stack runtime stack Globals, Globals, consts consts heap heap (direction of growth) (direction of growth) B University of Toronto 0000 0000 6024 6024 6356 6356 275000 275000 A C D Machine memory Machine memory addresses addresses 3 Activation Activation record/frame record/frame How to treat arguments? how to implement argument passing? Semantic model: In mode Out mode In/out mode Subprograms: parameter passing Subprograms: parameter passing University of Toronto Conceptual models of transfer: Physically move a value Move an access path(pointer) Implementation models: Pass by value Pass by result Pass by value-result Pass by reference 4 Pass by Value Initial value of parameters are copied from current values of arguments Final values of parameters are lost at return time (like local variables) Subprograms: parameter passing Subprograms: parameter passing University of Toronto 5 Pass by Value E.g. Subprograms: parameter passing Subprograms: parameter passing University of Toronto 6 Pass by Value Advantage: Arguments protected from change in callee Disadvantage: Copying of values takes execution time and space,...
View Full Document

This document was uploaded on 08/02/2011.

Page1 / 24

324-lecture20 - Principles of Programming Languages...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online