Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!news.duke.edu!eff!news.umbc.edu!haven.umd.edu!purdue!news.cs.indiana.edu!johnl@cs.indiana.edu
From: "John Lacey" <johnl@cs.indiana.edu>
Subject: Re: Arrays are just Vectors.
Message-ID: <1994Oct30.192000.19926@news.cs.indiana.edu>
Organization: Computer Science, Indiana University
References: <38nqnc$jdu@nyheter.chalmers.se> <30Oct1994.013423.Alan@LCS.MIT.EDU>
Date: Sun, 30 Oct 1994 19:19:56 -0500
Lines: 35

Alan@lcs.mit.EDU (Alan Bawden) writes:

>The real reason arrays are unnecessary is that you can just use -vectors-.
>The average access time for an array represented using nested lists is
>proportional to the size of the array -- not good.  Fortunately Scheme
>includes vectors, which have constant access time.

Unfortunately, Scheme does not have such vectors. See page 26:

    "[T]he average time required to access a randomly chosen
     element is typically less for the vector than for the list."

I have seen implementations (nay, even written them) which
represent vectors as balanced trees.

>Representing a two dimensional array using a vector of vectors gets you to
>within spitting distance of the performance of any other programming
>language's arrays.

As has been pointed out, you need to be able to spit pretty far
for this to work. It is easy enough to emulate the pointer
arithmetic and use a single vector to hold the multi-dimensional
array, however, and then even an average person could spit across
the remaining gap (which is mainly, as has been pointed at in yet
another place, range checking).

And this still fails unless your Scheme really has constant-time
access for vectors, which even I will admit is case for nearly
every implementation you will ever likely see.

I would point out, as Don Hosek recently did for typefaces,
that no programming language is useful in all cases. General-
purpose is a misnomer when applied to programming languages.

John L
