Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
kyub ( kyub@discuss.tchncs.de )  to Programmer Humor@programming.devEnglish · 2 years ago

The infamous "if loop" actually exists

discuss.tchncs.de

message-square
9
link
fedilink
115

The infamous "if loop" actually exists

discuss.tchncs.de

kyub ( kyub@discuss.tchncs.de )  to Programmer Humor@programming.devEnglish · 2 years ago
message-square
9
link
fedilink

alert-triangle
You must log in or # to comment.
  • LeFrog ( LeFrog@discuss.tchncs.de ) 
    link
    fedilink
    arrow-up
    12
    ·
    2 years ago

    ELI5 plz

    • Reil ( Reil@beehaw.org ) 
      link
      fedilink
      English
      arrow-up
      5
      ·
      2 years ago

      They used a macro to make ‘IF’ (which is distinctly not ‘if’) map to ‘while’. So it’s really a while(1) loop, which will repeat forever, or until the program is terminated, whichever comes first.

      Someone’s just being silly.

      • LeFrog ( LeFrog@discuss.tchncs.de ) 
        link
        fedilink
        arrow-up
        2
        ·
        2 years ago

        Thx!

        ‘IF’ (which is distinctly not ‘if’)

        Is this something needed “for the meme” or something with this macro or C/C++? Or why the case-sensitivity here? I only know languages like Java, Python, JS. Unfortunately the ancient tongue is not known to me.

        • Reil ( Reil@beehaw.org ) 
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 years ago

          It’s not really that important to the joke, since I’m pretty sure you can also replace keywords like ‘if’ with the preprocessor. It’s just that preprocessor macros are typically (style, not syntax) ALL_CAPS_WITH_UNDERSCORES.

          It’s just another clue that that block isn’t actually an if-block, since C is case sensitive and ‘IF’ wouldn’t actually work.

  • wise_pancake ( wise_pancake@lemmy.ca ) 
    link
    fedilink
    arrow-up
    9
    ·
    2 years ago

    Did you know python for loops have an else clause?

    Did you also know it runs after the loop iterator is done, and not when there was never anything to iterate over at all?

    https://docs.python.org/3/reference/compound_stmts.html#for

  • Tamlyn ( tamlyn@lemmy.zip ) 
    link
    fedilink
    arrow-up
    6
    ·
    2 years ago

    i have a colleague always saying if loop (in our language). I’m a bit to shy to tell him his mistakes… People easily hate me but i would like to…

  • TheReturnOfPEB ( TheReturnOfPEB@reddthat.com ) 
    link
    fedilink
    English
    arrow-up
    6
    ·
    2 years ago

    int* ihadatonepointforgottenaboutpoundefinesyoubastard {};

  • brian ( brian@programming.dev ) 
    link
    fedilink
    arrow-up
    5
    ·
    2 years ago

    found the following in our codebase the other day.

    while(booleanFlag)
        return;
    

    thhere wasn’t more in the loop body, that was it. the loop conditional does exist and it can hurt you.

  • katy ✨ ( cupcakezealot@lemmy.blahaj.zone ) 
    link
    fedilink
    arrow-up
    3
    ·
    2 years ago

    10 print “All Work, No Play”

    20 goto 10

    30 end

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
    • If the mod doesn’t find it funny, you’re banned. Ha-ha!.. For real: do not use the community for “statements”. There are other places for such content. Keep it chill and funny.
Visibility: Public
globe

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

  • 723 users / day
  • 1.74K users / week
  • 3.25K users / month
  • 7.28K users / 6 months
  • 463 local subscribers
  • 33.6K subscribers
  • 1.53K Posts
  • 25.2K Comments
  • Modlog
  • mods:
  • Feyter ( Feyter@programming.dev ) 
  • adr1an ( anzo@programming.dev ) 
  • BurningTurtle ( BurningTurtle@programming.dev ) 
  • Pierre-Yves Lapersonne ( pylapp@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code