Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
korrat6344yThere was a great explanation on here a while back: https://devrant.com/rants/1327341/.... The short version is: Arrays in Lua start at 1 because they aren't actually arrays.
-
Array indices != pointer offset
Indices are a logical construct pointing to logical units of the array, offsets a physical one based on C's concept of arrays as a block of memory divided into equal sized chunks
C uses offsets as indices, but there's no reason why indices can't start at 1. We still say "first element" for C index/offset 0. -
@Demolishun OMG Pascal, I began programming with that decades ago, and still feel dirty about it.
-
PacRat39904yits a c wrapper, idk why they coukdn't start at 0. they bribg over so many more programming fundamentals, its weird to leave that one out
-
@SortOfTested I jumped away from the whole ecosystem after highschool and never looked back.
Also, that was decades before Lazarus so that Delphi was pretty much Windows-only, which was exactly one of the things that have always sucked with Pascal - the balcanisation. -
@Fast-Nop
Always wondered how people in the Balkans felt about that term.
you missed out on the fun with Super Pascal Fighter Turbo Championship edition though. -
By default it starts at 1 doesn't mean you can't make it starting from 0?
I use lua as an extension language binding with Fortran, both languages have array index starting from 1, I found it quite handy
Related Rants
In lua, arrays starts at 1
What is this madness??
rant
arrays starts at 0
lua