This page is part of the web mail archives of SRFI 25 from before July 7th, 2015. The new archives for SRFI 25 contain all messages, not just those from before July 7th, 2015.
--- Per Bothner <per@xxxxxxxxxxx> wrote: > Jussi Piitulainen wrote: > > >Shall we switch, and is a vector good enough for an > index object? (I > >believe somebody asked for such packaging even > apart from efficiency.) > > > A modest but not order-or-magnitude difference on a > non-optimizing > implementation is not does not IMO justify a less > natural api. As the "somebody" in question I should explain why I feel this is a more natural api. Consider list processing in Scheme. Scheme is a 'closed world' for list processing - you never need operate on anything but lists because of fold and apply. I've written Scheme programs that have no other data structure, and I'm sure others have. Now I have two hypotheses: 1) We want a truly great language for array processing 2) We want that language to be Scheme If that is the case then there needs to be an array/function duality of the same kind we have for lists. I.e. you need to be able to pull apart arrays and use those parts to pull apart other arrays. So I advocate using arrays as indices to arrays (NB: there is no separate index object in this proposal). A simple example of why this is desireable: Imagine you have a 2-D array storing temparature measured at space and time, say samples from a number of weather stations over a period of days. temparature := array[location time] Now imagine that you want to be able to quickly find out the hotest measurement for each day (maybe you're working for the fire department and this is important information). So you have another array which indexes into the temparature array. hotest := array[time indexes] This is a 1 x 2 array, where column 0 corresponds to location and column 1 to time Now to find the hottest measurement for day 0 you would do something like this: The current proposal: (let ((location (array-ref hotest 0 0)) (time (array-ref hotest 0 1))) (array-ref temparatures location time)) My proposal: (array-ref temparatures (array-ref hotest #(0))) The first array ref returns the array-slice hotest[0:] The second uses that array slice to index into the temparatures array. In my opinion this is much cleaner code. I hope that clears things up. Noel __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1