logoalt Hacker News

zephentoday at 2:58 AM1 replyview on HN

Truly, indentation is the moveable feast. Even on ancient typewriters, you could adjust your tabs depending on what you are doing. And people who have dissimilar tastes in tabbage will certainly write stuff that doesn't appear that great in each others' editors.

> What business does a compiler have worrying about display width?

The business of the compiler is to insure that code that it deems acceptable is not ambiguous to different users. Since people can set their own tab spacing, display of tabs is, in an indentation-sensitive language, inherently ambiguous.

> What if I choose to program in a variable width font?

As long as the spacing of any prepended whitespace doesn't arbitrarily change depending on the phase of the moon, the compiler shouldn't (and Python doesn't) give a rat's ass about your display preferences.

The only important thing here is that the location of the left margin on every line is meaningful, both to the compiler, and to any viewers of your code.


Replies

fc417fc802today at 5:32 AM

> people who have dissimilar tastes in tabbage will certainly write stuff that doesn't appear that great in each others' editors.

Not for code, no. People will do that for spaces. For tabs it's a 1:1 correspondence with indentation level with any visual adjustments done by the editor.

Reading between the lines I suspect you are operating with the flawed idea of using tabs for alignment. One must never use tabs for alignment purposes because they very explicitly do not have a fixed width. (They have a consistent width within a document at any given point in time but it is entirely arbitrary and can change at any time.)

> insure that code that it deems acceptable is not ambiguous to different users ... display of tabs

A compiler never has any control over display. It must ensure no _semantic_ ambiguity. And indeed there isn't any to be found here. Even in python where you can introduce an arbitrary amount of whitespace when going up a level of indentation there is never any semantic ambiguity.

In short you are confused about the division of labor within the stack of abstractions.

> The only important thing here is that the location of the left margin on every line is meaningful, both to the compiler, and to any viewers of your code.

I'd dispute that the compiler needs to care about where your editor places the left margin. However rather than argue about bizarre hypothetical text editors that do unhinged things when displaying whitespace for no apparent reason, I'll instead observe that it seems to follow from what you said that you actually agree with me. As long as the prefix remains consistent across a given level of indentation then there's no cause for concern.