Replies: 4 comments 13 replies
-
FWIW I am sympathetic to indentation-sensitive languages, I rather like them! We did have some discussion about this in the very early days of PRQL. But they're a totally different type of language; it's not viable to have "just a bit of indentation-sensitivity" given how pervasive it is — even more so for whether users should have to worry about indentation when writing PRQL than us overhauling the parser. Newlines are quite different from indentation in that respect. |
Beta Was this translation helpful? Give feedback.
-
There might be areas in which the parser can be a little smarter with respect to newlines, when it "knows" that a Legal:
Illegal:
If I had used an explicit
If a newline is encountered where it's not syntactically legal for a Note: I edited the above code snippet. |
Beta Was this translation helpful? Give feedback.
-
I'm looking at the other pipelined query languages, and they've all adopted a syntax which requires the pipe character to be specified. If PRQL adopted a similar strategy, then newlines aren't syntax anymore, and the need for word wrapping goes away too. |
Beta Was this translation helpful? Give feedback.
-
I noticed that if the first keyword on a line is |
Beta Was this translation helpful? Give feedback.
-
It looks like the line wrap syntax with the leading backslash is there mainly to prevent erroneously defining a new pipeline stage. In other contexts (tuples, etc.) no special line wrap character is needed. Personally, I find the use of the backslash to be visually distracting, and knowing when to use it might be confusing for new users.
Is it possible instead to require that a new pipeline stage be non-indented, within the current scope? Thus the example in the book would simply be:
Because each "country" line is indented, it's clear that it's an extension of the is_europe expression.
I can see how this approach does cause some issues, because indenting currently has no effect on syntax. Leaving it out does simplify the parser. But the parser already treats newlines as syntax, which special rules, and so there is some precedent for treating whitespace as syntax.
Beta Was this translation helpful? Give feedback.
All reactions