• Drew Belloc
    link
    fedilink
    arrow-up
    38
    ·
    1 year ago

    Amateur! I use coments so it looks like this:

    function main(){ /tab/if(fish==2){ /tab//tab/console.log(“i need help”); /tab/} }

    • gnuswannOP
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Him: I spend 3months on this project Me: how many lines does it takes now? Him: I would say around one line of code

  • lasagna
    link
    fedilink
    arrow-up
    19
    ·
    edit-2
    1 year ago

    3 spaces is best because if the universe is chaos then everything in it should reflect that.

    • soundasleep@kbin.social
      link
      fedilink
      arrow-up
      23
      ·
      1 year ago

      I’m more about increasing spaces exponentially to really highlight how important each line is

      public boolean function() {
       if (method()) {
         if (otherMethod()) {
             for (Object o : list()) {
                     if (o.isAlive()) {
                                     return false;
                     }
             }
         }
       }
       return true;
      }
      
      
      • lasagna
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        For line in lines: if char[0] == SPACE { del char[0]} else if char[0] == TAB {char[0] = SPACE*3}

        save(‘overwrite’)

    • chaorace@lemmy.sdf.org
      link
      fedilink
      arrow-up
      12
      arrow-down
      2
      ·
      1 year ago

      For real. OP needs to give up on this ridiculous notion of tabbed whitespace and learn to use real, monospaced indentation. How wide is a tab? OP couldn’t tell you because tabs are inherently dishonest – a lie concocted by big keyboard to poison the unwashed programmer masses.

  • ZILtoid1991@kbin.social
    link
    fedilink
    arrow-up
    14
    ·
    edit-2
    1 year ago
    int mostCursedIndentation (const int someVal) @safe {
    {}{}if (someVal < 0) {
    {}{}{}{}throw new Exception ("Value cannot be negative!");
    {}{}}
    {}{}return someVal * 5 - 3;
    }
    
    
    • vvv@kbin.social
      link
      fedilink
      arrow-up
      18
      ·
      1 year ago

      i dont wanna talk about the lua version of this

      local function someFunction(arg)
      do end local SomeLocal = 40;
      do end if arg > SomeLocal then
      do end do end SomeLocal = Somelocal + arg
      do end elseif arg < SomeLocal then
      do end do end arg = arg * 2
      do end do end if SomeLocal > arg then
      do end do end do end error("oh my god why are you trying to read this")
      do end do end end
      do end end
      do end return SomeLocal
      end
      
      someFunction(-0.3000000000000124976137894613978561389741642978623178913786926473891)
      
      
  • neil
    link
    fedilink
    arrow-up
    9
    ·
    1 year ago

    I just want Coke to bring back Tab and Pepsi to introduce a competing drink called Space

  • thkruz
    link
    fedilink
    arrow-up
    7
    ·
    1 year ago

    …this…this can’t be real…no one is that much of a sadist are they?

    This whole thread is what nightmares are made of.

    • deaf_fish@lemm.ee
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      So at my work we’ve implemented a automatic code formatter. Instead of having discussions about the process of changing the configuration file we just put it up on GitHub. I think I might have found a fun April fool’s prank.

  • jxk@sh.itjust.works
    link
    fedilink
    arrow-up
    6
    ·
    1 year ago

    I know why it’s there, but it still annoys me that there’s a semicolon on the last line

  • RiikkaTheIcePrincess@kbin.social
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Oh, that’s weird. Kinda not that bad- … wait, where are the semi…co…lon…s… What? OH NO!! What the fuck! Hahahah, that’s awful. There’s some real bad stuff in this thread, but that first one is deceptively awful. Whew.

    Really missing Haskell now :P

  • Speiser0@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    If people want me to write into my code what it does, I guess I’ll label everything:

    #include <iostream>
    #include <cstdint>
    
    #pragma GCC diagnostic ignored "-Wunused-label"
    
    int main()
    {
    A:int a = 4;
    B:if ((uintptr_t)&a & 0x100)
    BA:std::cout << "hi" << std::endl; else
    BB:std::cout << "hello" << std::endl;
    C:return 0;
    }
    

    Note that this is much better for code style because - as opposed to the semicolon indentation- the single statement if and else branches still work. The trailing else is on the same line on purpose, it’s so small it doesn’t need its own line. Here’s another style with similar properties:

    [[,]]int a = 4;
    [[,]]if ((uintptr_t)&a & 0x100)
    [[,,]]std::cout << "hi" << std::endl; else
    [[,]]std::cout << "hello" << std::endl;
    [[,]]return 0;