6 ms·
What I never get about the huge Lua popularity in C/C++ land is how people manage the mental switch between 0-based and 1-based indexing. Or is this tunable fro
by dualogy 3y ago
What I never get about the huge Lua popularity in C/C++ land is how people manage the mental switch between 0-based and 1-based indexing. Or is this tunable from the VM/JIT-hosting side? Because if I were to use Lua-the-language standalone, I'd lose all my "mental automatics" for real basic arraying/looping stuff that serve in day to day in the non-Lua workloads of C/++, Go, the occasional TypeScript etc.
- defrost 3y agoIt might be because I'm old and grew up with carpentry and fence and post around a paddock real life problems but there's no switch if you seperate the two as two distinct things. If you make a pigeon hole row of boxes, box number 1 has an index of 1 and an offset of 0 (from the origin mark). C arrays are syntactic sugar for origin based offsets, Fortran arrays are indexed by element number. In C arr[i] is equivalent to i[arr] is equivalent to arr + i and to i + arr.