Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Remember, UNIX spelled backwards is XINU. -- Mt.


devel / comp.lang.fortran / Re: “Why do arrays start at 0?"

SubjectAuthor
o “Why do arrays start at 0?"Thomas Koenig

1
Re: “Why do arrays start at 0?"

<teg56c$lbs$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9869&group=comp.lang.fortran#9869

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-4e56-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: “Why do arrays start at 0?"
Date: Sun, 28 Aug 2022 16:30:04 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <teg56c$lbs$1@newsreader4.netcologne.de>
References: <tebblf$2gpm$1@dont-email.me> <pvbOK.866404$ntj.801728@fx15.iad>
<fnumghl55e20valikh9oerct1bhk1g178r@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 28 Aug 2022 16:30:04 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-4e56-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:4e56:0:7285:c2ff:fe6c:992d";
logging-data="21884"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 28 Aug 2022 16:30 UTC

Charlie Roberts <croberts@gmail.com> schrieb:
> On Fri, 26 Aug 2022 16:08:20 -0600, Louis Krupp
><lkrupp@invalid.pssw.com.invalid> wrote:
>
>>On 8/26/2022 2:49 PM, Lynn McGuire wrote:
>>> “Why do arrays start at 0?"
>>> https://buttondown.email/hillelwayne/archive/why-do-arrays-start-at-0/
>>>
>>> "It's not the reason you think. No, it's not that reason either.”
>>>
>>> My Fortran starts at one.  My C++ starts at zero.  This has made my
>>> life hell.
>>>
>>
>>Here's a crude outline of a solution:
>>
>>If you want a C++ array index to start at 1, make the array one element
>>bigger than necessary, and start indexing at 1, just like in Fortran.
>>Element 0 will be unused.
>>
>>If you want a C++ array to map exactly to a Fortran array, but with an
>>index starting at 1, wrap the C++ array in a class and overload the
>>subscripting operator(s) to subtract 1 from the index.
>>
>>Neither of these approaches seems elegant, but one of them should be
>>less hellish than the other.
>>
>>Louis
>
> The authors of "Numerical Recipes" started out with F77 and so all the
> code in their first book has arrays starting at 1. When they brought
> out the C version, they resorted to just this trick!

Ugh.

I never read the C (or C++) versions, the latest one I used is
the 2nd edition in Fortran 77 (which I still have within reach at
my desk).

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor