Design issues of subprogram

Subprogram:

A subprogram means a function or procedure.

For example

void main()
{
}
int show()
{
}

Some of the design issues of subprogram are:

  • Are local variables static or dynamic?
  • Can subprogram definitions appear in other subprogram definitions?
  • What parameter-passing method or methods are used?
  • Are the types of the actual parameters checked against the types of the formal parameters?
  • If subprograms can be passed as parameters and subprograms can be nested, 
  • what is the referencing environment of a passed subprogram?
  • Can subprograms be overloaded?
  • Can subprograms be generic?
  • If the language allows nested subprograms, are closures supported?

Some definitions to be know:

1. An overloaded subprogram

An overloaded subprogram is one that has the same name as another subprogram in the same referencing environment. 

2. A generic subprogram

A generic subprogram is one whose computation can be done on data of different types in different
calls.

3. A closure

A closure is a nested subprogram and its referencing environment, which together allow the subprogram to be called from anywhere in a program.