From: Phlip Date: 2007-07-19T12:25:07+09:00 Subject: Re: The Pebble in the Ruby Shoe Joel VanderWerf wrote: > If you're working in set theory, you get in the habit of 0 based indexing, > because then the index set is an ordinal number, i.e. ordinal n = {0, ..., > n-1}. > > In other branches (esp. algebra), it has the advantage that you can treat > the indexes as a cyclic group, do modular arithmetic, etc. > > In general, 0 based indexing makes it easier to make the leap from a list > of variables to a function with a natural domain. Another way to say this is languages should lead programmers to think in terms of set theory, not simplistic natural numbers, because the former is much more sustainable. Imagine a language that used 1-based indexing. It would make working in 0-based appallingly hard even for simple situations. So we would prefer this slippery slope to slide in the correct direction. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax