Block Structure
Block Structure
Recursion:
Overview of Management
Static-scope rules for block structured languages:
Overview of Management
Local data and local referencing environment:
Overview of Management
Scope rule for local referencing environment:
1. Retention
2. Deletion
Overview of Management
Retention
Overview of Management
Deletion:
Overview of Management
Advantages and Disadvantages:
Overview of Management
Shared data
The data objects within the block are visible within the
subprograms and may be referenced by name in usual way.
Overview of Management
Inheritance:
1.Formal parameters
2. Actual parameters
Overview of Management
Establishing the correspondence between the parameters
1.Positional correspondence:
The actual and formal parameters are paired based on their respective positions
in actual and formal parameter lists.
The first actual parameter is bound to the first formal parameter and so forth.
When the parameter list is long then programmer can make mistakes in the order
of parameters in the list, for it we use keyword parameter.
For example in Ada sum(x-->a, y-->b), It pairs formal parameter x with actual
parameter a and y with b.
Overview of Management
Semantic models of parameter passing
There are three methods:
IN mode: In it values are passed to the subprogram being called i.e. formal
parameters can receive data from the corresponding actual parameters.
OUT mode: It returns values to the caller of the subprogram i.e. formal
parameters can transmit data to the actual parameter.
OUT formal parameter act as a local variable and its value can be changed in any
way.
IN OUT mode: In it initial values are passed to the subprogram being called and
return updated values to the caller.
1.Call by value
2.Call by reference
3.Call by result
4.Call by name
5.Call by value-result
6.Call by constant value
Overview of Management
Call by result
Disadvantages:
Overview of Management
Call by value result
Disadvantages:
Disadvantages:
3. Difficult to implement.
Overview of Management
Call by constant
Advantages:
1.Protecting the calling program from changes in actual parameter
Overview of Management