• SolidGrue
    link
    fedilink
    English
    60
    edit-2
    8 months ago

    Looks like Python, but in an editor with a weird TUI scrollbar

      • @_stranger_@lemmy.world
        link
        fedilink
        38 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.

        • @frezik@midwest.social
          link
          fedilink
          18 months ago

          IIRC, Python handles whitespace indentation by having the tokenizer convert them to INDENT/DEDENT tokens. The grammar can then handle them equivalently to a curly brace language.

        • @takeda@lemmy.world
          link
          fedilink
          38 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
            2
            edit-2
            8 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.

            • @takeda@lemmy.world
              link
              fedilink
              18 months ago

              I see. I would love to be proven wrong, but I don’t see a way this would work with tabs/spaces in python.