3 ms·
Just like Python, Haskell only ever has significant indentation.
by lucian1900 14y ago
Just like Python, Haskell only ever has significant indentation.
- eridius 14y agoUntrue. While it's true that most people use the 'layout' rule, which is the significant whitespace, there is a non-whitespace-significant variant that uses braces and semicolons. You can see an example of how layout is expanded to the alternative syntax at http://www.haskell.org/onlinereport/lexemes.html#lexemes-layout http://www.haskell.org/onlinereport/lexemes.html#lexemes-lay...
- lucian1900 14y agoNo, I meant that Haskell doesn't consider any whitespace that isn't indentation as significant.
- eridius 14y agoVery few languages consider non-indentation whitespace as significant (not counting using whitespace as a token delimiter, which Haskell definitely does, e.g. "foo bar" =/= "foobar").
- lucian1900 14y agoYes, but many people assume whitespace everywhere will matter when they hear Python's offside rule described. It's a misconception I've found is worth dispelling, since almost no one minds meaningful indentation.
- the_mitsuhiko 14y agoRuby and CoffeeScript do and their syntax relies heavily on it.
- vidarh 14y agoFor Ruby at least "heavily" is a big exaggeration. It is significant as a token separator and in cases where inserting a line break makes the expression up to the line break a valid expression in itself, in which case it is treated as one. You pretty much only need to remember to separate tokens where lack of whitespace might create a different vald token, and ensure any expressions that you want to let span more than one line ends with something that expects following tokens to make a complete expression. Personally I can live with that easily. I can not live with significant indentation, on the other hand...
- the_mitsuhiko 14y ago`foo()` and `foo ()` are different things in ruby, so are `foo[x]` and `foo [x]`. That is significant whitespace.