Hacker News new | past | comments | ask | show | jobs | submit login

Indentation is semantic only in Python (which incidentally uses spaces). In any other language it's a purely visual property - the code works the same regardless of indentation.



I think you've misunderstood the use of semantic here - it's semantic for all text files. Instead of describing very exactly 'put 8 spaces here' you're saying 'for some reason this line needs to be indented once, take this information display this as you wish.'


> Indentation is semantic only in Python

And in Haskell. And in Nim. And in Haml. And in Sass. And in YAML.

https://en.wikipedia.org/wiki/Off-side_rule#Off-side_rule_la...


Indentation is semantic has in it carry a meaning. We are not talking about how a specific language use it.

As for Python, it doesn't use space. It can use both spaces and tabs (but not mixed within the same file). It's just that PEP-8 require spaces, but not every project/library follow PEP-8.


In those languages where it is not semantic, proper indentation still gives visual clues to the semantics: With proper indentation one can read programs in lots of languages even without their specific semantic markers. A simple way to see this is to configure your editor's syntax highlighting to use the background color for parenthesis, semicolons or whatever the markers are in your language of choice.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: