Docsity

Parameter Passing and Verification in Modern Programming Languages, Exercises of Programming Languages

Toggle sidebar
bg1
program verification is intimate
- Verification is impossible with goto’s
- Verification is possible with only selection and
logical pretest loops
- Verification is relatively simple with only
guarded commands
Modern Programming Languages
Lecture # 45
Actual/Formal Parameter Correspondence:
1. Positional
2. Keyword
e.g. SORT(LIST => A, LENGTH => N);
Default Parameter Values
procedure SORT(LIST : LIST_TYPE;
LENGTH : INTEGER := 100);
...
SORT(LIST => A);
Parameters and Parameter Passing
Semantic Models
- in mode, out mode, in-out mode
docsity.com
pf3

Partial preview of the text

Download Parameter Passing and Verification in Modern Programming Languages and more Exercises Programming Languages in PDF only on Docsity!

program verification is intimate

  • Verification is impossible with goto’s
  • Verification is possible with only selection and logical pretest loops
  • Verification is relatively simple with only guarded commands

Modern Programming Languages

Lecture # 45

Actual/Formal Parameter Correspondence:

  1. Positional
  2. Keyword

e.g. SORT(LIST => A, LENGTH => N);

Default Parameter Values

procedure SORT(LIST : LIST_TYPE; LENGTH : INTEGER := 100); ... SORT(LIST => A);

Parameters and Parameter Passing

Semantic Models

  • in mode, out mode, in-out mode

Conceptual Models of Transfer

  1. Physically move a value
    1. Move an access path

Implementation Models

1. Pass-by-value (in mode) - Either by physical move or access path 2. Pass-by-result (out mode)

  • Local’s value is passed back to the caller
  • Physical move is usually used
  • Disadvantages: Collision Example: procedure sub1(y: int, z: int); ...

sub1(x, x);

3. Pass-by-reference (in-out mode) i. Actual parameter collisions e.g. procedure sub1(a: int, b: int); ... sub1(x, x);

ii. Array element collisions e.g. sub1(a[i], a[j]); /* if i = j */

iii. Collision between formals and globals

Root cause of all of these is: The called subprogram is provided wider access to Non-locals than is necessary

Type checking parameters

- Now considered very important for reliability - FORTRAN 77 and original C: none - Pascal, Modula-2, FORTRAN 90, Java, and Ada: it is always required