<br><br><div><span class="gmail_quote">On 5/1/06, <b class="gmail_sendername">Jecel Assumpcao Jr</b> &lt;<a href="mailto:jecel@merlintec.com">jecel@merlintec.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Wolfgang Helbig wrote on Mon, 1 May 2006 14:02:19 +0200 (MEST)<br>&gt; And that is my point: Different challenges need different numbers for the first<br>&gt; index. When I am implementing a Gaussian algorithm to invert matrices, I'd never
<br>&gt; use 0 as the first index. But whenever I am computing indexes, I'd never use<br>&gt; one as the first index. And this is not supported by BASIC and Smalltalk.<br><br>To be fair, I have used more than one BASIC that allowed you to set
<br>either 0 or 1 as the base index for all arrays in a program. And the<br>Self dialect of Smalltalk (<a href="http://www.merlintec.com:8080/Self/">http://www.merlintec.com:8080/Self/</a>) does<br>borrow several C conventions including 0 based arrays.
<br><br>The current program I am writing in Squeak simulates hardware and 1<br>based arrays were a bit inconvenient, so the first thing I did was<br>define a ZArray class as a subclass of ArrayedCollection with<br><br>at: index
<br>&nbsp;&nbsp;^ super at: index + 1<br><br>at: index put: obj<br>&nbsp;&nbsp;^ super at: index + 1 put: obj<br><br>do: block<br>&nbsp;&nbsp; 0 to: self size - 1 do:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ :index | block value: (self at: index) ]<br><br>and then all I had to do was write the rest of my application naturally
<br>and just remember to use &quot;ZArray new: x&quot; instead of &quot;Array new: x&quot;.<br>Inspecting ZArrays still shows the contents as having indexes starting<br>with 1, but other than that small confusion (which I could easily fix if
<br>I wanted to) it works just great. There is probably a significant<br>performance hit but I am not worried about that here.</blockquote><div><br>This seems to me to be a good approach. I think Alan Kay said something like &quot;hardware is just software crystallized early&quot;. If one accepts that notion then the special needs of hw should properly be subsets of the typical case. Perhaps, when the world is running on Plurion processors, that will come to pass ;-)
<br><br>Laurence<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">-- Jecel<br><br></blockquote></div><br>