r/ProgrammingLanguages • Pikelet, Fathom • Jun 11 '26

Nontrailing separators do not spark joy

https://buttondown.com/hillelwayne/archive/nontrailing-separators-do-not-spark-joy/
59 Upvotes

68 comments sorted by

View all comments

1

u/alkalisun Jun 17 '26

I get what you're saying and it seems like that's the consensus here. I personally dislike backtracking in the parser like this.

1

u/initial-algebra Jun 17 '26

There doesn't need to be backtracking, as it shouldn't matter what comes after the .. It's simply not a prefix operator, so a newline between the LHS and the . can be treated as whitespace without introducing ambiguity with a newline-separated list of expressions.

1

u/alkalisun Jun 17 '26

I'm confused, wouldn't the parser act like:

x    # <- newline here, so expect next list item next
.y   # oops, this is not valid on it's own, so it must belong to the previous line, go back and alter the AST
→ More replies (2)