From: Prentice Bisbal <pbis...@pppl.gov> Date: Tuesday, October 20, 2020 at 9:40 AM To: John Hearns <hear...@gmail.com>, Jim Lux <james.p....@jpl.nasa.gov> Cc: "Renfro, Michael" <ren...@tntech.edu>, "beowulf@beowulf.org" <beowulf@beowulf.org> Subject: Re: [Beowulf] ***UNCHECKED*** Re: Re: [EXTERNAL] Re: Re: Spark, Julia, OpenMPI etc. - all in one place
Indexing from zero - who ever heard of zero of a thing. Damn quiche eaters. I've heard it explained this way: Index zero requires zero offset from the start of the array's memory address, so the index presents how many offsets the item is away from the start of the array. Makes more sense when you think of it that way. But again, it makes more sense in lower languages like C than it does in "higher" languages like Fortran and Python where memory addressing details aren't exposed to the programmer. Prentice Exactly – it’s a nice thing in C, because C isn’t really implementing arrays per se, the Array variable is a pointer, and the a[i] notation is basically a shorthand for pointer arithmetic. And it’s close to the target executable. I think, when C was first developed, folks weren’t worrying about optimizers, for instance. You can do horrible things like int a[100]; /* some code */ a[i] = *(a+j); /* someone using both array style and pointer style references, just because they can */ and a = &somehexconstant; Handy for mapping to a buffer of characters at some address, but full of traps for the unwary
_______________________________________________ Beowulf mailing list, Beowulf@beowulf.org sponsored by Penguin Computing To change your subscription (digest mode or unsubscribe) visit https://beowulf.org/cgi-bin/mailman/listinfo/beowulf