Discussion
No Semicolons Needed
marcosdumay: Looks at 11 languages, ignores Haskell or anything really different...
gcanyon: Can anyone give a good reason why supporting syntax like: y = 2 * x - 3 is worth it?
justsomehnguy: Mostly eye-candy, especially for some long one-liners.In PowerShell you can do that by explicitly instructing what the next line is actually a continuation of the previous one: $y = 2 * $x ` - 3
sheept: > I would love to see a language try to implement a rule where only an indented line is considered part of the previous expression.Elm does this (so maybe Haskell too). For example x = "hello " ++ "world" y = "hello " ++ "world" -- problem
IshKebab: > how does Gleam determine that the expression continues on the second line?The fact that it isn't obvious means the syntax is bad. Stuff this basic shouldn't be ambiguous.> Go's lexer inserts a semicolon after the following tokens if they appear just before a newline ... [non-trivial list] ... Simple enough!Again I beg to differ. Fundamentally it's just really difficult to make a rule that is actually simple, and lets you write code that you'd expect to work.I think the author's indentation idea is fairly reasonable, though I think indentation sensitivity is pretty error-prone.
szmarczak: It's not. Your eyes can deceive you by guessing the correct indentation. Indentation should never be used for grammar separation. Explicit characters such as } ] ) are clearer and unambiguous.
bmandale: Clearer for the computer, but not for the human. Many errors, some severe, have been caused by a human only looking at the indentation and not realizing the braces don't match.
bmandale: > I would love to see a language try to implement a rule where only an indented line is considered part of the previous expression.After python, it seems like every language decided that making parsing depend on indents was a bad idea. A shame, because humans pretty much only go by indents. An example I've frequently run into is where I forget a closing curly brace. The error is reported at the end of the file, and gives me no advice on where to go looking for the typo. The location should be obvious, as it's at exactly the point where the indentation stops matching the braces. But the parser doesn't look at indents at all, so it can't tell me that.
librasteve: This article makes a strong case for every language to use ‘;’ as a statement separator.
kayson: Are we really saving that much by not having semicolons? IDEs could probably autocomplete this with high success, and it removes ambiguity from weird edge cases. On the other hand, I've not once had to think about where go is putting semicolons...
kayson: I was much more opposed to this early on than I am now. With modern IDEs and extensions handling tabs vs spaces, tab width, and formatting, python ends up being very easy to read and write. I use it daily, and while I hate it for other reasons, I can't remember the last time I had any issues with indentation.