Closed jimin-kiim closed 1 year ago
subprogram definition
: the interface to and the actions of the subprogram abstractionsubprogram call
: an explicit request that the subprogram be executedsubprogram header
: the first part of the definition, including the name, the kind of subprogram, and the formal parametersparameter profile (aka signature)
: the number, order, and types of its parametersprotocol
: a subprogram’s parameter profile and, if it is a function, its return typeprototypes
: Function declarations in C and C++ subprogram declaration
: provides the protocol, but not the body, of the subprogramformal parameter
: a dummy variable listed in the subprogram header and used in the subprogramactual parameter
: a value or address used in the subprogram call statementdef __add__ (self, second) :
return Complex(self.real + second.real, self.imag + second.imag)
function makeAdder(x) {
return function(y) {return x + y;}
// The closure is the anonymous function returned by makeAdder
}
...
var add10 = makeAdder(10);
var add5 = makeAdder(5);
document.write(′′add 10 to 20: ′′+add10(20)+′′<br />′′);
document.write(′′add 5 to 20: ′′+add5(20)+′′<br />′′);
resume
: a coroutine callquasi-concurrent execution
of program units (the coroutines); their execution is interleaved, but not overlapped