A Tuesday 08 June 2010 23:34:09 Anne Archibald escrigué: > > But the issue isn't one of efficiency, it's merely an arbitrarily chosen > > convention. (Does anyone know the history of the choices for FORTRAN and > > C, esp. why K&R chose the opposite of what was already in common usage in > > FORTRAN? Just curious?) > > This is speculation, not knowledge, but it's worth pointing out that > there are actually two ways to represent a multidimensional array in > C: as a block of memory with appropriate type definitions, or as an > array of pointers to subarrays. This latter approach is generally not > used for numerical work, but is potentially useful for other > applications. More relevantly, it already has a natural syntax; > a[2][3][5] naturally follows the chain of pointers and gives you what > you want; it also forces your last index to change most rapidly as you > walk through memory. So it would be very odd if multidimensional > arrays defined without pointers but using the same syntax were indexed > the other way around. (Let's ignore abominations like 5[3[2[a]]].)
Hey, maybe it is only speculation, but this is the most convincing argument for breaking Fortran convention that I've ever heard (although I'm not sure if C was really breaking Fortran convention, as both languages should have born more or less in time, although I'd say that Fortran is a bit older). -- Francesc Alted _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion