music

# parameters

## summary

This subchapter looks at parameters.

## free computer programming text book project

If you like the idea of this project,

### stub section

This subchapter is a stub section. It will be filled in with instructional material later. For now it serves the purpose of a place holder for the order of instruction.

Professors are invited to give feedback on both the proposed contents and the propsed order of this text book. Send commentary to Milo, PO Box 1361, Tustin, California, 92781, USA.

# parameters

This subchapter looks at parameters.

Here are five basic methods for transmitting parameters:

(1) Value (Ada, ALGOL 60, Pascal) The formal parameter identifies a local variable in the procedure or function. The local variable is initialized to the argument value at the time of the procedure or function call. Assignments to the local variable do not affect the caller. Callby value may be a strict value transmission, in which case the formal parameter identifies a local constant rather than a lcoal variable.

(2) Result (Ada) The formal parameter identifies a local variable in the procedure or function. The local variable has an undefined initial value. Upon return the contents of the local variable are assigned to the argument in the caller (if the argument is a variable).

(3) Value/ResultAda, FORTRAN)> The formal parameter identifies a local variable in the procedure or function. The local variable is initialized to the argument value at the time of the procedure or function call. Upon return the contents of the local variable are assigned to argument in the caller (if the argument is a variable). The argument may be fixed at or before the time of the call or it may be redetermined upon return.

(4) Reference (Ada, FORTRAN, Pascal) A reference (usually a pointer) to the argument is transmitted to the procedure or function. Operations on the formal parameter that occur within the procedure or function are performed via the reference. If the argument is an expression, the compiler constructs a temporary variable.

(5) Name (ALGOL 60) A parameterless procedure p is transmitted to the procedure or function. The procedure p creates a reference to the argument. If the argument is an expression, then p computes the value of the expression, stores that value in a temporary variable, and provides a reference to the temporary variable. All operations on the formal parameter invoke p and use the reference generated by p.

Very few programming languages explicitly specify parameter transmission mechanisms. The mechanism chosen can vary from compiler to compiler for the same language. Depending on a particular compiler’s choices for transmission methods can make a program difficult to understand and can cause lack of portability, not just to different machines, but even to later versions of the same compiler.

Of course, if the language specifies the transmission methods and gives specific constructs to indicate the method chosen, then the programmer is free to make use of the choices available.

“15 A subprogram is the basic unit for expressing an algorithm. There are two kinds of subprograms: procedures and functions. A procedure is the means of invoking a series of actions. For example, it may read data, update variables, or produce some output. It may have parameters, to provide a controlled means of passing information between the procedure and the point of call. A function is the means of invoking the computation of a value. It is similar to a procedure, but in addition will return a result.” —:Ada-Europe’s Ada Reference Manual: Introduction: Language Summary See legal information

“24 A procedure call invokes execution of a procedure after associating any actual parameters provided at the call with the corresponding formal parameters.” —:Ada-Europe’s Ada Reference Manual: Introduction: Language Summary See legal information

“36 Access types allow the construction of linked data structures. A value of an access type represents a reference to an object declared as aliased or to an object created by the evaluation of an allocator. Several variables of an access type may designate the same object, and components of one object may designate the same or other objects. Both the elements in such linked data structures and their relation to other elements can be altered during program execution. Access types also permit references to subprograms to be stored, passed as parameters, and ultimately dereferenced as part of an indirect call.” —:Ada-Europe’s Ada Reference Manual: Introduction: Language Summary See legal information

“43 Finally, the language provides a powerful means of parameterization of program units, called generic program units. The generic parameters can be types and subprograms (as well as objects and packages) and so allow general algorithms and data structures to be defined that are applicable to all types of a given class.” —:Ada-Europe’s Ada Reference Manual: Introduction: Language Summary See legal information

“1 Ada is a programming language designed to support the construction of long-lived, highly reliable software systems. The language includes facilities to define packages of related types, objects, and operations. The packages may be parameterized and the types may be extended to support the construction of libraries of reusable, adaptable software components. The operations may be implemented as subprograms using conventional sequential control structures, or as entries that include synchronization of concurrent threads of control as part of their invocation. The language treats modularity in the physical sense as well, with a facility to support separate compilation.” —:Ada-Europe’s Ada Reference Manual: Section 1: General See legal information

### other

“11. If you have a procedure with 10 parameters, you probably missed some.” —Alan Perlis, Epigrams on Programming, ACM’s SIGPLAN Notices Volume 17, No. 9, September 1982, pages 7-13

# free music player coding example

Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

View music player in action: www.musicinpublic.com/.

Create your own copy from the original source code/ (presented for learning programming).

## view text bookHTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

 previous page next page
 Tweets by @osdata

## free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

Some or all of the material on this web page appears in the

This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

†UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

Names and logos of various OSs are trademarks of their respective owners.