26 points · by pbnaidu · 18y ago · 13 comments
What is your quest? To conquer the world with Visual Basic.
At what index shall arrays start? One... no, zero... (arghhhhhhh.....)
Was it thrown away?
Is it... still running? {o_O}
I hope they're starting their migration/risk mitigation strategies now.
- Array allocations are done using helper macros which invoke malloc and return a pointer to memory one element before the beginning of the array. (I'm pretty sure this is undefined behaviour according to the standard btw; it just happens that the format of pointers isn't data-dependent anymore these days)
- Array accesses are just as usual in C, except array[1] is the first element.
- Freeing memory is again wrapped in a macro to calculate the actual beginning of the array.
- Multidimensional arrays are layers of this crap.
Actually, I probably would have provided the numerical recipes code in two versions, one in the 1-based format, the other in idiomatic C.
But then I'm more of a software engineer than a computational physicist even though my degree certificate claims otherwise.