This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CSC 324: Principles of Programming Languages Procedural Language Design Issues READING: Sebesta 4.3,4.4,4.84.10; 8.18.5,8.11; 9.19.5 c Suzanne Stevenson 2001 1 Part VI: Procedural Language Design Issues Procedures: A Control Abstraction A block of code that can be called imperative) A lambda expression functional) A horn clause logic programming) Procedures modularize program structure 2 Components of a Procedure 1. Name 2. Formal parameters, optionally with types parameter formal parameter) Local variable whose value is received from caller argument actual parameter) The info passed from caller to callee 3. Body, which is a syntactic construct in the language: Block, i.e., declarations and statements Expression Conjunction of terms 4. Optional result, optionally with a type 3 Procedure Implementation Issues The general notion of a procedure leaves a number of points unspecified: How to pass parameters when the procedure is called How to maintain local state and control information How to access non-local names within a procedure body 4 Parameter Passing Matching arguments with parameters: 1. Positional association: Arguments are associated with parameters left to right 2. Keyword association: Arguments are given tags, eg: procedure plot (x,y: real; penup: boolean) ... plot(0.0, 0.0, penup=>true) plot(penup=>true, x=>0.0, y=>0.0) 5 Parameter Passing 3. Optional arguments: E.g., C printf . . . ) Extra arguments are packaged into some structure Passed to special parameter 6 Passing Modes How to treat arguments pass-by-x/call-by-x):...
View Full Document
This note was uploaded on 02/05/2011 for the course CS 24 taught by Professor Cathy during the Summer '10 term at University of Toronto- Toronto.
- Summer '10
- C Programming