• _stranger_@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        6 months ago

        Heh, so in Python it’s possible to overload operators in the context of objects. I bet it would be possible to overload tabs to do the same thing as colons inside a context manager, but that’s pure speculation.

        • takeda@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          6 months ago

          Perhaps I don’t understand you, but I don’t think there’s a way to override spaces in python in any way. The spaces are handled by the parser.

          • _stranger_@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            edit-2
            6 months ago

            You can define what happens for an object when an operator is applied (like +, /, or -) so that you can obj+obj. I wonder if there’s a way to override “tab” such that it acts like a “:”, but from inside the language (this is trivial if you edit the language itself like you suggest). Thinking about it more, I’m guessing not since “:” isn’t an operator and this doesn’t have a corresponding __operator__ function.

            • palordrolap@kbin.run
              link
              fedilink
              arrow-up
              0
              ·
              6 months ago

              If Python has anything like Perl’s source code filters, then anything’s up for grabs, but Perl is kind of weird in a way that Python was specifically designed not to be. Or at least Python 1 was. Things may have changed in the intervening couple of decades.

              If it’s just plain overloading, then whitespace is probably off the table. Spaces, even required spaces, aren’t so much syntax as they are structure. You could argue that the curly braces of some other languages are more syntactic than Python’s whitespace, because it’s actually Python’s magic colon and the first unindented line (lack of whitespace!) that serve that specific syntactic purpose.

              Examples of Perl’s source code filters range from turning a program into binary representation of the syntax tree and still having it be executable, to new syntax, to writing programs entirely in Latin or something that looks almost but not entirely unlike it, anyway.

    • subignition@fedia.io
      link
      fedilink
      arrow-up
      0
      ·
      6 months ago

      High chance that it’s a Python programmer who is really unhappy about having to work in Java, lol

  • TunaCowboy@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    6 months ago

    What if I prefer this?

     #define CURLYOPENRIGHTCLOSEDLEFTBRACKET {
     #define CURLYOPENLEFTCLOSEDRIGHTBRACKET }
     #define CURVYOPENRIGHTCLOSEDLEFTBRACKET (
     #define CURVYOPENLEFTCLOSEDRIGHTBRACKET )
     #define PERIODWITHPERIODONTOP :
     #define COMMAWITHPERIODONTOP ;
    
     int main CURVYOPENRIGHTCLOSEDLEFTBRACKET CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
       if CURVYOPENRIGHTCLOSEDLEFTBRACKET 1 CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
        asm volatile CURVYOPENRIGHTCLOSEDLEFTBRACKET
    

    “mov $1, %%rax\n”          “mov $1, %%rdi\n”          “lea message(%%rip), %%rsi\n”          “mov $4, %%edx\n”          “syscall\n”          PERIODWITHPERIODONTOP          PERIODWITHPERIODONTOP          PERIODWITHPERIODONTOP “%rax”, “%rdi”, “%rsi”, “%rdx”      CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP CURLYOPENLEFTCLOSEDRIGHTBRACKET return 0 COMMAWITHPERIODONTOP CURLYOPENLEFTCLOSEDRIGHTBRACKET

    asm CURVYOPENRIGHTCLOSEDLEFTBRACKET ".section .data\n"
      "message: .ascii \"wut\\n\"\n"
      ".section .text\n" CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
    
  • MystikIncarnate@lemmy.ca
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 months ago

    I’m not a coder, and… Well… Thanks, I hate it.

    Even I know this is horrific. Where the fuck does this statement end? Which of these brackets refer to this section of other brackets. Idfk.

    I could give a shit less if it was just for a single block per or something but “;}}}” hurts me.

    • velvetThunder@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      6 months ago

      Well the code indentation explains that, like python. The issue is not reading it. You would rather quit your job than edit this.