Re: Arrays and general functions

1992-09-08 Thread Ken Sailor

David Barton writes:

 And finally, it makes sense to have separate syntax for arrays and
 general functions, because different behavior is expected for the two.
 
 Here, I may be exposing my cluelessness, but this seems a (search for
 a better word ---  none found) silly statement.  There are many cases
 where we want different behavior to be expressed by the same syntax.

Well, perhaps behavior is the wrong word.  Also, I find your approach
interesting. 

On the other hand, general functions and arrays are typically mixed
in a program.  If the distinction between the two is limited to type
declarations, then from my perspective it becomes difficult to read
and understand programs.  The difference between functions as rules
and arrays to me is much more significant than the difference between
adding reals and adding integers.  From your perspective, maybe any
distinction gets in the way.  In practice, I have not had this problem.

Ken




Arrays and general functions

1992-09-08 Thread David Barton

Ken Sailor writes:

On the other hand, general functions and arrays are typically mixed in
a program.  If the distinction between the two is limited to type
declarations, then from my perspective it becomes difficult to read
and understand programs.  The difference between functions as rules
and arrays to me is much more significant than the difference between
adding reals and adding integers.  From your perspective, maybe any
distinction gets in the way.  In practice, I have not had this
problem.

The distinction indeed gets in the way; however, this may well be a
product of the application area in which I am working (I *did* admit
my bias in all this).  If we define the behavior of an engineering
component in a microwave system by a function, the distinction between
whether that function is defined by an array (table of values) or a
rule (a function definition in the present Haskell sense) had better
be hidden!  We want very much to treat these independent of the
mechanism of defining them.

I am interested in how the lack of a distinction gets in the way of
your reading and understanding programs, however.  After all, I do
want to make sure we are not introducing problems here!  Granting that
this is a somewhat theoretical discussion, could you elaborate a bit
here?  What kind of expression would become difficult to understand if
the distinction between arrays and rule-defined functions was hidden?
I don't want to impose on your time unreasonably, but a couple of
small examples might be helpful.

Dave Barton
[EMAIL PROTECTED]




Re: Arrays and general functions

1992-09-08 Thread Reginald Meeson

Interesting discussion, but it seems to me that Haskell already
provides the best of both worlds, namely

  a. Efficient implementation of arrays as data objects, with indexing
 as a projection function; and

  b. Definition of functions with (Ix a) domains by indexing an array
 behind the scenes or by any other rule.

Arrays satisfy the needs of an important user community.  Is there
something more needed to satisfy the general-function community?