• Drew Belloc@programming.dev
    link
    fedilink
    arrow-up
    36
    ·
    2 years ago

    Amateur! I use coments so it looks like this:

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

  • ZILtoid1991@kbin.social
    link
    fedilink
    arrow-up
    13
    ·
    edit-2
    2 years ago
    int mostCursedIndentation (const int someVal) @safe {
    {}{}if (someVal < 0) {
    {}{}{}{}throw new Exception ("Value cannot be negative!");
    {}{}}
    {}{}return someVal * 5 - 3;
    }
    
    
    • chaorace@lemmy.sdf.org
      link
      fedilink
      arrow-up
      10
      arrow-down
      2
      ·
      2 years 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.

  • jxk
    link
    fedilink
    arrow-up
    10
    ·
    2 years ago

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

  • thkruz@programming.dev
    link
    fedilink
    arrow-up
    7
    ·
    2 years 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
      ·
      2 years 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.

  • Speiser0@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    2 years 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;