Tuesday, February 3, 2015

Chapter 9 : Review Question

Q6 : What is a Ruby array formal parameter?
A : Ruby supports a complicated but highly flexible actual parameter configuration. The initial parameters are expressions, whose value objects are passed to the corresponding formal parameters. The initial parameters can be following by a list of key => value pairs, which are placed in an anonymous hash and a reference to that hash is passed to the next formal parameter. These are used as a substitute for keyword parameters, which Ruby does not support. The hash item can be followed by a single parameter preceded by an asterisk. This parameter is called the array formal parameter.

Q7 :  What is a parameter profile? What is a subprogram protocol?
A : Parameter profile is the number, order, and types of its formal parameters.
Subprogram protocol is its parameter profile plus, if it is a function, its return type. In languages in which subprograms have types, those types are defined by the subprogram’s protocol.

Q8 : What are formal parameters? What are actual parameters?
A : Formal parameters are the parameters in the subprogram header.
Actual parameters are a list of parameters to be bound to the formal parameters of the subprogram which must be included with the name of the subprogram by the subprogram call statements.

Q9 : What are the advantages and disadvantages of keyword parameters?
A : The advantage of keyword parameters is that they can appear in any order in the actual parameter list. The disadvantage to keyword parameters is that the user of the subprogram must know the names of formal parameters.

Q10 : What are the differences between a function and a procedure?
A : A function returns value but procedures do not. Function are structurally resemble procedures but are semantically modeled on mathematical parameter.

No comments:

Post a Comment