[PATCH] CCR Import from CSV: Calculate correct nitrogen and helium gas pressures

Robert Helling helling at atdotde.de
Mon Nov 3 13:07:23 PST 2014

On 03 Nov 2014, at 18:08, Dirk Hohndel <dirk at hohndel.org> wrote:

>> Just as a general rule: “1” is never a good name for anything except the
>> smalls non-negative integer.
> Oh I love that... I may have to quote you at some point.

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. 

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?!?“).

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.

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).

I try hard to avoid integer indices unless they are really asked for.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20141103/42840bda/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20141103/42840bda/attachment.sig>

More information about the subsurface mailing list