lemmy.imagisphe.re
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Jaromil@fed.dyne.org to Programmer Humor@lemmy.ml · 1 年前

Off by one solitude

fed.dyne.org

message-square
145
link
fedilink
1.49K

Off by one solitude

fed.dyne.org

Jaromil@fed.dyne.org to Programmer Humor@lemmy.ml · 1 年前
message-square
145
link
fedilink
  • sgibson5150@slrpnk.net
    link
    fedilink
    arrow-up
    18
    arrow-down
    1
    ·
    1 年前

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

    • dohpaz42@lemmy.world
      link
      fedilink
      English
      arrow-up
      11
      arrow-down
      1
      ·
      1 年前

      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.

      • affiliate@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        1 年前

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

        • jaybone@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          1 年前

          Maybe this could be a feature in brainfuck or COBOL.

          • affiliate@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            1 年前

            god i hope so

        • Vorthas@lemmy.ml
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 年前

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

          https://github.com/TodePond/DreamBerd

          • affiliate@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            1 年前

            what a beautiful language

    • Zagorath@aussie.zone
      link
      fedilink
      arrow-up
      2
      ·
      1 年前

      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.

      • lefixxx@lemmy.world
        link
        fedilink
        arrow-up
        5
        arrow-down
        1
        ·
        1 年前

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

      • ReversalHatchery@beehaw.org
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 年前

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

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

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: !programmerhumor@lemmy.ml

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.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 8 users / day
  • 646 users / week
  • 1.98K users / month
  • 7.06K users / 6 months
  • 1 local subscriber
  • 39.6K subscribers
  • 1.82K Posts
  • 32.2K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.13
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org