halubilo.social
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Jaromil to Programmer [email protected] • 9 months ago

Off by one solitude

fed.dyne.org

message-square
145
fedilink
1.49K

Off by one solitude

fed.dyne.org

Jaromil to Programmer [email protected] • 9 months ago
message-square
145
fedilink
  • @[email protected]
    link
    fedilink
    18•9 months ago

    Wouldn’t it be nice if documentation used the words index and offset consistently?

    • dohpaz42
      link
      fedilink
      English
      10•9 months ago

      The problem is that they both are contextual and can mean any position in a list/array. The starting index or starting offset is generally zero, but could be one, depending on the language used.

      • @[email protected]
        link
        fedilink
        4•9 months ago

        i wonder why people haven’t made a language that starts indexing at 2 yet. maybe some day

        • @[email protected]
          link
          fedilink
          4•9 months ago

          Maybe this could be a feature in brainfuck or COBOL.

          • @[email protected]
            link
            fedilink
            2•9 months ago

            god i hope so

        • @[email protected]
          link
          fedilink
          English
          2•9 months ago

          Dreamberd starts array indexing at -1 instead of 0 or 1.

          https://github.com/TodePond/DreamBerd

          • @[email protected]
            link
            fedilink
            1•9 months ago

            what a beautiful language

    • Zagorath
      link
      fedilink
      2•9 months ago

      Aren’t those two the same thing? At least in C-style arrays, which might not be how they’re handled under the hood, but is at least how most languages present it to the programmer.

      • @[email protected]
        link
        fedilink
        4•9 months ago

        Yes they are presented in the programmer wrong. The first thing in memory should have offset 0 and index 1

      • @[email protected]
        link
        fedilink
        English
        3•9 months ago

        in my understanding offset is technically the “relative index”, or how much you have to go further

Programmer [email protected]

[email protected]

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 82 users / day
  • 1.92K users / week
  • 3.21K users / month
  • 9.62K users / 6 months
  • 36K subscribers
  • 1.74K Posts
  • 37.5K Comments
  • Modlog
  • mods:
  • @[email protected]
  • @[email protected]
  • BE: 0.19.3
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org