I like David Barton's idea of distinguishing between the
array representation of functions and the more familiar
computational representation at the declaration level
but not at the reference level.  With this appraoch
references to arrays and references to functions would
look the same in expressions, which is appealing because
they express the same concepts.   Declarations would give the
processor hints about possible economies of implementation.

At least one language I know of suggests, in its syntax,
the similarity between functions and arrays: Fortran.
Subsequent languages have, unfortunately, failed to follow
Fortran's good example in this regard.  I tried to get the
Fortran 90 standards committee to continue the metaphor to
data structures so that references to components would look
like function references and be distinguished from them only
in the declarations.  The committee didn't buy the idea,

A question that came up in the Fortran 90 discussions on
the syntax of references to components of data structures:
Which is the function and which the argument?  Fortran
syntax views the array as the function and the subscript as
the argument.  The other way around seems better for data
structures because component names are constant entities and
different instances of the data structure are the (variable)
data that might act as arguments to (selector) functions
denoted by the names of components.

This might work for arrays, too:

    traditional references
    (array is function,           a 1,  a 2, ...
     subscript is argument)

    other way around
    (subscript is function,       1 a,  2 a, ...
     array is argument)

In the alternative formulation, the integers name
polymorphic functions mapping arrays of various types
into the base type of those arrays. But there is a problem
with dereferencing a variable subscript in this formulation:
(n a) should mean "apply the function named by the integer
value of n to the array a" rather than "apply the function
named n to a".

The traditional formulation gets the referencing right,
though, doesn't it?  And it seems to apply equally well
to lists.  Writing (lst n) to select the n-th element of
lst looks good and draws an appropriate analogy to functions.

Rex Page

Reply via email to