[E-Lang] An Attempted Restatement of Hydro's Semantics

Bill Frantz frantz@pwpconsult.com
Mon, 2 Apr 2001 15:32:08 -0700


At 8:21 AM -0700 4/2/01, Marc Stiegler wrote:
>Looking at this from a theory perspective (wo, big mistake, me trying to
>talk from a theory perspective...here goes anyway), what are the
>circumstances under which the programmer has enough information to
>meaningfully reach inside an array and pick an element?
>
>Well, the first and last elements are special, so you sometimes reach for
>them with list[0] and list[size-1]. But this is covered by getHead/getTail
>
>A middle element can be special if the list has been specially constructed
>to contain a specific number of elements at carefully specified positions,
>in which case you would want to "unload" them into elements with better
>names (this is usually a terrible programming practice of course, and is
>rarely necessary in modern languages...though I do use it in E in the
>limited context of returning pairs the way BrandMaker and PromiseMaker do).
>This is covered by E's breakout syntax.
>
>Finally, if the middle elements are not special, the only meaningful way to
>reach them is through iteration.

One case where the middle elements are special is when doing a binary
search.  Matrix inversion, multiplication etc. also make interesting uses
of indexing.  It might be a useful experiment to see what an E matrix
inversion routine looks like.

BTW - It seems to me that most of the use of indexing is for performance.
Using indexing for byte translation is probably a big performance win over
hash tables.  (A big enough win that the IBM 360 has an instruction which
does just that.)

<random-thoughts>
There seems to be a dichotomy between people who work with sorted data, and
those that use hash table like structures.  Historically, sorted data was
very popular because you could efficiently store it on sequential access
devices like cards or tape.  Merging/matching two sorted lists was a common
enough operation that languages such as RPG and Adpac (sp?) had it built
into their core.
</random-thoughts>

-------------------------------------------------------------------------
Bill Frantz       | Microsoft Outlook, the     | Periwinkle -- Consulting
(408)356-8506     | hacker's path to your      | 16345 Englewood Ave.
frantz@netcom.com | hard disk.                 | Los Gatos, CA 95032, USA