16
urco
4y

In lua, arrays starts at 1
What is this madness??

Comments
  • 7
    Late to the party :p
  • 5
    @alexbrooklyn That's what index 1 means LOL
  • 7
    Hey Lua, would you Pascal the salt please?
  • 3
    There 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.
  • 4
    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.
  • 4
    @Demolishun OMG Pascal, I began programming with that decades ago, and still feel dirty about it.
  • 0
    MS Excel wants to know your lpcation
  • 6
    What the fuck is lua
  • 5
    @scout embeddable scripting language often used in games for modding.
  • 1
    @Demolishun ooo okay. I’d never heard of it before, I’m getting out of touch
  • 0
    its 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
  • 5
    In real life, you start counting at 1. What ist this madnesssszzz???!!!oneoneeleven
  • 0
  • 0
    ❌❌❌Nope..
  • 3
    @Fast-Nop
    How do you feel about Delphi then?
  • 2
    @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.
  • 1
    @korrat This also means that you can make it start at 0, right?
  • 2
    @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.
  • 2
    @kescherRant yes. I fact you can make it anything. It's a key/value list.
  • 1
    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
Add Comment