• magic_lobster_party@kbin.run
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    I’m more concerned about that poor stack with all those recursions.

    It’s also O(n^2). I’m not sure what they’re trying to do, but I’m sure it can be done in O(n).

    Reject.

  • NigelFrobisher@aussie.zone
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    5 months ago

    My credo on this kind of thing is never do something that will make your successor so mad that they find out where you live and post parts of your body to Interpol.

      • _stranger_@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        5 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
          ·
          5 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
            5 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
              ·
              5 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
      ·
      5 months ago

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

  • GissaMittJobb@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    Automatically enforced deterministic formatting is the best, there’s nothing that beats it. The productivity in just being able to format on save knowing that the code will be in the ideally formatted state, along with the anti-bikeshedding properties of this strategy, makes it unbeatable.

    • h0bbl3s@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

      gofumpt and gofmt are the best. One of the reasons if I have a choice I’ll code in go. I heard rumblings that rust was working towards having rustfmt be a standard crate.

      • GissaMittJobb@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        5 months ago

        Go is in a good position, yeah. JavaScript has prettier, which is nice. Java has google-java-format. Python has ruff, which is quite good. Kotlin has ktfmt, which I believe made a mistake with their standards by not following the standard formatting guidelines for the language, but whatever. Uniform and deterministic for the win.

      • Username@feddit.org
        link
        fedilink
        arrow-up
        0
        ·
        5 months ago

        What do you mean? rustfmt is the de facto standard and is easily run using cargo fmt. Most projects use it along with clippy, the standard linter.