Print

Print


As usual, Van Snyder has given us a lot to chew on.  However, it's not
exactly clear what his position on this issue is.  I can restate the basis
of his dilemma (perhaps) as the following choice:

  Is it better for the language to strive toward a uniform means of reference
  by (among other things) having array and function references use the
  same syntax?

or

  Is it better, since uniform reference in the existing language would be difficult
  to achieve and is now certainly incomplete, for the language to use syntax
  which makes the distinctions clear by (among other things) having array
  subscripting and function arguments differently delimited?

I still don't know which opinion Van Snyder supports (and perhaps
he intended it that way).

Van Snyder <[log in to unmask]> wrote:
>James Giles wrote:
>
>> Actually, I prefer subscripts and functions to have the same syntax.
>> That way (though it's rare) you can replace a function on integers
>> with a predefined array, or vice-versa, without recoding the rest of 
>> your program.  This isn't a strongly felt bias, but I do prefer it.
>
>One more frequently wishes to go the other way -- change an array to a
>procedure -- because of some increase of requirements.

Actually, I more often switch from a function to an array after deciding
that a table look-up is more efficient than the function I was using.
A change of requirements that disallows the continued use of an array
usually involves additional changes as well - requiring much rewriting
regardless of whether the syntax of the references is the same or not.
Mileage may vary of course.

>The "correct" semantics are as in POP-2 or CURL:  When a procedure reference
>is the LHS of an assignment, the RHS is a hidden argument to an "updater"
>procedure that is invoked after the RHS is evaluated.  It is responsible for
>storing (or whatever it wants to do) the RHS.  A "function" and "updater"
>are a joined-at-the-hip pair -- if you have one you have the other one --
>just like an array.  BTW, an array is a function/updater pair for which
>the compiler knows how to write the bodies of the procedures, and then
>inlines them.

I'll have to look at those more closely (I'm afraid I've not studied POP-2
and never even seen CURL).  But, this seems to require that functions
be rather closer to first-class entities than is the case in Fortran (or C,
C++, etc...).  Would it not require, at least, the ability to deal with
higher-order functions (functions whose domain and/or range had
functional type)?

> [...]                                                                    When structures
>were being developed ca. 1996, there was a faction that advocated a
>functional syntax of reference, i.e. component(structure) instead of
>structure%component.  They obviously lost the battle.

Minor note: presumably you meant 1986.

--
J. Giles



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%