{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

324-lecture20 - Principles Principles of Programming...

Info icon This preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Principles of Programming Languages Lecture 20 University of Toronto Wael Aboulsaadat [email protected] http://portal.utoronto.ca/ 1
Image of page 1

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

View Full Document Right Arrow Icon
Components of an Imperative Language Data types Variables, operators & Expressions Iteration construct Branching construct University of Toronto barb2right Subprogram construct Container construct 2
Image of page 2
Subprograms: big picture Sample memory layout A program with 4 sub-programs: A, B, C and D code runtime stack Globals, consts heap (direction of growth) B University of Toronto 0000 6024 6356 275000 A C D Machine memory addresses 3 Activation record/frame
Image of page 3

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

View Full Document Right Arrow Icon
How to treat arguments? how to implement argument passing? Semantic model: In mode Out mode In/out mode Conceptual models of transfer: Subprograms: parameter passing University of Toronto 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
Image of page 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 University of Toronto 5
Image of page 5

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

View Full Document Right Arrow Icon
Pass by Value – E.g. Subprograms: parameter passing University of Toronto 6
Image of page 6
Pass by Value – Advantage: Arguments protected from change in callee – Disadvantage: Copying of values takes execution time and space, especially for aggregate values Subprograms: parameter passing University of Toronto – PLs: C, Pascal, Ada, Scheme, Algol68 7
Image of page 7

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

View Full Document Right Arrow Icon
Pass by Result No initial value of parameters Final values of parameters are copied back to arguments Subprograms: parameter passing University of Toronto 8
Image of page 8
Pass by Result Subprograms: parameter passing University of Toronto 9
Image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern