<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 03 Nov 2014, at 18:08, Dirk Hohndel <<a href="mailto:dirk@hohndel.org">dirk@hohndel.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Just as a general rule: “1” is never a good name for anything except the<br>smalls non-negative integer.<br></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">Oh I love that... I may have to quote you at some point.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></blockquote></div><br><div>Besides the fact that I misspelled „smallest“and the fact that 1 is the smallest positive integer, this is actually one of the very few things I learned about programming. I have never received any formal education in computer science or anything like that and have done my share of spaghetti coding as a kid. But I had pretty much lost interest in programming when I entered university. </div><div><br></div><div>That was only revived when I learned about perl from a fellow graduate student which was in many ways much more what I liked compared to languages like C (with declared variables and so many ways to shoot yourself in the food with pointers etc). One of the many things I liked so much about perl is that „array“ as a data type (or rather structure), the thing that is indexed by integers, has much fewer uses than the C programmer thinks. Many things that look like arrays are actually lists, where reasonable operations are first, next or last elements, shifting, concatenating and of course iteration are typical operations but „give me element number 17“ rarely is. And with foreach it is so much harder to produce an obi wan error than with for (i=0; i <= 17; i++) {} („Should it be <17?!?“).</div><div><br></div><div>And if you need a structure of indexed objects, indices are rarely again integers, they can be anything in which case what looks like an array is actually a hash. With that you can say „give me the dillutant cylinder“ rather than „give me cylinder 1“ („or was it 0?!?“) and again you can interate etc etc.</div><div><br></div><div>In any case, this realisation really struck me and I think it is really important to use the correct type for index sets (or none at all) but using integers suggests so many wrong things (like the possibility to do arithmetic on them) while in the cases above all one really uses that every finite set can be bijectively mapped to exactly one set of the form {0, 1, 2, …, n} but that map is not canonical (if you like the language of category theory).</div><div><br></div><div>TL;DR</div><div>I try hard to avoid integer indices unless they are really asked for.</div><div><br></div><div>Best</div><div>Robert</div></body></html>