Crony's Dungeon
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 3 months ago

// Implement

lemmy.zip

message-square
18
link
fedilink
163

// Implement

lemmy.zip

Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 3 months ago
message-square
18
link
fedilink
alert-triangle
You must log in or register to comment.
  • MyTurtleSwimsUpsideDown@fedia.io
    link
    fedilink
    arrow-up
    38
    ·
    3 months ago

    implemented

  • Lembot_0004@discuss.online
    link
    fedilink
    arrow-up
    37
    arrow-down
    1
    ·
    edit-2
    6 days ago

    deleted by creator

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      28
      arrow-down
      4
      ·
      3 months ago

      that’s why c++ gets bullied

      • Lembot_0004@discuss.online
        link
        fedilink
        arrow-up
        10
        arrow-down
        3
        ·
        edit-2
        6 days ago

        deleted by creator

        • Eager Eagle@lemmy.world
          link
          fedilink
          English
          arrow-up
          19
          arrow-down
          1
          ·
          3 months ago

          yes, but in this particular case I wouldn’t want to second guess my decrement operation just happens to also be calling the white house or whatnot. Just make a method.

          • SpaceNoodle@lemmy.world
            link
            fedilink
            arrow-up
            7
            arrow-down
            1
            ·
            3 months ago

            It is a method!

            • Eager Eagle@lemmy.world
              link
              fedilink
              English
              arrow-up
              5
              arrow-down
              2
              ·
              3 months ago

              thanks

          • leo85811nardo@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            3 months ago

            That’s just life of a C++ programmer: you second guess everything, and there are still optimization you haven’t tried, and pitfalls you haven’t got into

          • leo85811nardo@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            3 months ago

            deleted by creator

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          13
          ·
          3 months ago

          Until the next person with a slightly different mental way of defining things comes along. Or just a future version of you.

        • mkwt@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          3 months ago

          But when you do shoot yourself in the foot, it blows your whole leg off.

          • Lembot_0004@discuss.online
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            6 days ago

            deleted by creator

            • Avicenna@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              2 months ago

              Actually

              https://neshobademocrat.com/stories/man-accidentally-shoots-his-foot-with-shotgun,121925

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      15
      ·
      3 months ago

      Yeah, just to say it more clearly: that kind of thing is why lots of people out there insist that operator overloading is a bad idea.

      And yeah, it’s a C++ thing that mostly doesn’t happen in other languages.

      • TeamAssimilation@infosec.pub
        link
        fedilink
        arrow-up
        3
        ·
        3 months ago

        Sincerely agree. Explicit is better then implicit, that’s a general engineering axiom.

        Instead of overloading and making the next maintainer hunt for overloads, a clearly named function that does the critical steps would make the code immensely more maintainable. C++ is C gone wild.

    • melechric@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      3 months ago

      Yes. Sometimes you’re limited by the hardware you’re controlling. This code is a bit hard to justify with that excuse though. Normally your code would do a read from hardware to see if the value decremented and then repeat the write. (Possibly a sleep/yield in there if required.)

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    ·
    3 months ago

    a logical skeuomorphism, how eccentric

    • mobotsar@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      3 months ago

      Haha! I had the same thought.

  • unalivejoy@lemmy.zip
    link
    fedilink
    arrow-up
    10
    ·
    edit-2
    3 months ago

    Thank goodness for the JIT and compiler optimizations.

    • setVeryLoud(true);@lemmy.ca
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      …would JIT optimizations even help here?

  • anton@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    8
    ·
    3 months ago

    If those are normal integers, the compiler optimizes that to a simple compare and branch/cmov.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      3 months ago

      for others - https://godbolt.org/z/osaKrxsPx

Programmer Humor@programming.dev

programmer_humor@programming.dev

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: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

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

  • 1.63K users / day
  • 3.98K users / week
  • 7.68K users / month
  • 17.4K users / 6 months
  • 1 local subscriber
  • 27.1K subscribers
  • 1.71K Posts
  • 52.3K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org