Topic: procedure valued variables

topics > computer science > data > Group: procedure and type-valued variables


database agents
exception handling with resumption
function call
function signature
object-oriented methods
parameter passing by name
pointers to data
procedures as data
program blocks for control
uniform reference to data
user interface tool kits
variable as function that accesses an object's value


A variable may indicate a procedure. The procedure itself is usually not accessible. Instead the variable indicates a code location, parameter types, and a calling sequence. In Cedar, they are called "registered procedures" since they have been registered by the variable's owner for execution on demand. Procedure valued variables may provide the name for a procedure definition (e.g., "sin := (X):real ...end;") or process (e.g., "P := FORK readline (terminal)").

Procedure valued variables may be parameters to other functions. In Cedar, these are called "call-back procedures" since the procedure body can call-back the caller. They are widely used in user interface programming and increase the flexibility of procedure interface design. They also complicate the code and increase the complexity of control flow.

Object-oriented programming uses procedure valued members for dynamic dispatch. An object includes a pointer to a table of routines. Invoking a method (or, "sending a message") calls the corresponding routine.

Garbage collection simplifies the task of managing memory assigned to parameters of call-back procedures. (cbb 5/80, 1/90, 10/97)

Subtopic: procedure parameters, call-back up

Quote: procedure arguments increases the flexibility of an interface; e.g., a procedure instead of a mini-language for testing some property [»lampBW10_1983]
Quote: a call-back procedure is a procedure parameter in Cedar
Quote: a GP routine can take an executable argument by specifying its starting address; called plug-in coding [»randS_1957]
Quote: upcalls usually call a higher level function through a procedure variable

Subtopic: first-class value up

Quote: Mesa processes are first-class values; created by fork/join operators [»lampBW2_1980]
Quote: files in OS6 are first-class values; access heading and body by file handle; heading contains information about file [»stoyJE3_1972]

Subtopic: pointer to function up

Quote: while a C function is not a variable [i.e., no function arrays], a pointer to a function is a first-class value [»ritcDM7_1978c]
Quote: replace function pointers with function objects and interfaces; a function object exports exactly one method [»blocJ_2001]

Subtopic: function table up

Note: an interface is an indirect call through a field of a function table using a standard calling convention [»cbb_2000, OK]

Subtopic: events up

Quote: can register an 'interest' in an object to be called on any update;e.g., to resize a button when its label changes; simpler than constraints [»pausR10_1992]
Quote: Mesa's user interface Tajo allows programs to register adjust, wakeup, and sleep procedures with a window [»sweeRE7_1985]
Quote: IGD actions can be attached to the page itself; executed whenever page is accessed [»feinS1_1982]

Subtopic: messages defined by procedure components up

Quote: most abstractions in XDE were objects represented by a record with procedure variables to implement its operations [»sweeRE7_1985]
Quote: an Oberon handler is a procedure-valued variable or record field; caller doesn't know callee, so it's "sending a message" [»wirtN9_1989]
Quote: in LIS, a structure component can invoke a function [»ichbJD_1973, OK]
QuoteRef: hallJC5_1974 ;;48 self-processing data structures eg */'proc' accesses procedure field

Subtopic: stream function up

Quote: an I/O stream manipulator is a function that takes a stream as input and returns a stream; use it to insert functions like 'flush()' and 'skipspacing()' in a list of input or output operations [»stroB_1991]
Quote: OS 6 streams are first class objects; assign to variables, use as parameters, returned by stream functions; e.g., RemoveLayoutChs to remove layout from a stream [»stoyJE3_1972]

Subtopic: block parameters, anonymous procedures up

Quote: in Smalltalk build control structures by block parameters; i.e., executable code [»deutLP8_1981]

Subtopic: wrappers up

Quote: a private procedure for a procedure variable may call standard procedures; used for extensions and experimentation [»sweeRE7_1985]

Subtopic: examples up

Quote: a registered procedure is a procedure-valued variable in Cedar
Quote: use an auxiliary subroutine for the integrated function in numerical quadrature [»wilkMV_1985]
Quote: while a C function is not a variable [i.e., no function arrays], a pointer to a function is a first-class value [»ritcDM7_1978c]
Quote: the value of a procedure object is its definition; it may have an optimized, compiled version as well [»heerJ4_1985]
QuoteRef: simscrip_1971 ;;32 subprogram variables and arrays eg let subr= 'sqrt.f' which can be referenced by call or indirection ($subr===sqrt.f
QuoteRef: sammJE5_1962 ;;144 ALTER to change the target of a procedure name
QuoteRef: wegbB5_1974 ;;6 routine valued variables eg foo <-expr (x:real; char) begin...end is a character valued function of one real argument
QuoteRef: gescCM6_1975 ;;34 a procedure object may be assigned a procedure-body as a value procedure literals same as normal procedures
QuoteRef: wegbB_1971 ;;258 treats procedure as a mode (like integers)
QuoteRef: ziegEW4_1974 ;;131 procedure may be associated with an element and the location of an element can be saved.

Subtopic: garbage collection up

Quote: garbage collection increases flexibility of argument passing to procedure parameters and variables [»swinDC7_1985]

Subtopic: problems of call-backs up

Quote: call-backs in a user interface tie the application code to a toolkit; small interface changes often require many rewritten call-backs [»myerBA11_1991]
Quote: callback-based programming was difficult to teach through SUIT; accustomed to using program flow to encode state [»pausR10_1992]
Quote: toolkits for user interfaces require call-backs for every widget, many trivial; hard to maintain [»myerBA11_1991]

Related Topics up

Group: function   (12 topics, 232 quotes)
Group: parameters   (10 topics, 145 quotes)

Topic: database agents (10 items)
Topic: exception handling with resumption (31 items)
Topic: function call (28 items)
Topic: function signature (21 items)
Topic: object-oriented methods (42 items)
Topic: parameter passing by name (11 items)
Topic: pointers to data (55 items)
Topic: procedures as data (22 items)
Topic: program blocks for control (20 items)
Topic: uniform reference to data (34 items)
Topic: user interface tool kits (31 items)
Topic: variable as function that accesses an object's value
(21 items)

Updated barberCB 3/06
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.