• Linus Torvalds added hidden tabs to Kconfig to challenge parsers that can’t handle them.
  • Tabs were intentionally added to the common Kconfig file for page sizes to expose faulty parsers.
  • Torvalds believes parsers unable to handle tabs shouldn’t be parsing kernel Kconfig files, aiming to force fixes.
  • barsoap@lemm.ee
    link
    fedilink
    arrow-up
    5
    arrow-down
    1
    ·
    7 months ago

    Python for example supposedly only allows 4 spaces for indentation, but as long as the developer is consistent most if not all Python interpreters will accept any kind of indentation.

    That’s a recipe for disaster as your syntax is under-specced. You’re right-up inviting programmers to produce programs with implementation-defined semantics.

    Haskell (which also uses layout syntax) never had that problem as tabs were simply defined to be eight spaces, but that then led to issues with people setting different tab-widths in their editors and a flurry of syntax errors when they did “tabs for indentation, spaces for alignment”. Which is why Haskell then moved ahead to outlaw tabs, I think it’s still in the “throw a warning” phase but at some point it’s going to be a hard error.

    That’s not to say that kconfig should do the same – presumably they used tabs for a good reason, and all those other programs are simply not following the spec. Essentially including unit tests in the actual production files is a good move when you’re dealing with that kind of situation.

    • UndercoverUlrikHD@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      7 months ago

      Eight space indentation should be crime, I’m not made out screen width over here.

      If you want to be strict with indentation, use tabs as your standard instead of forcing others to use your preferred visual width.

      • barsoap@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        7 months ago

        Eight is still the default tab width and will be as long as VT100 continues to be a thing, i.e. forever. Haskell could’ve chosen another static value but that would have caused even more trouble.

        With Haskell’s syntax you really want to align at single-space resolution, not necessarily just on the left but also further to the right, within the lines. The gold standard is pretty much lhs2tex “poly” style (section 8, page 19), and not just because it allows lhs2tex to spit out beautiful code, it’s also highly readable in ASCII form. In that style 2+ spaces mean “align this with the 2+ space stuff above and below”.

        So there’s no way around spaces and as tabs+spaces are a bad idea tabs get the boot. That argument is specific to Haskell but in general I’d argue that tabs are more trouble than they’re worth – if you have trouble editing space-only indentation, get a proper editor. If I want my Rust indented by a different amount I can just tell rustfmt to change everything, no biggie.