-
Notifications
You must be signed in to change notification settings - Fork 45
Relax the indentation requirement #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've looked at the implementation in #159, and I like it. I like that we can relax the acceptance of the parser without reducing the readability of the spec. I also agree that we should continue to serialize with indention. I'd also stick to serializing with trailing-} indent for now. Mostly because that allows us to not immediately push all implementations to production ;-) I'm happy to have a separate conversation about that in a quarter or so, though. |
I like it. There's one thing I'm wondering about, both from the parser, and from the human eye perspective and it taps to the long standing debate about how the reader spots new message while scanning a file. One opinion is that it happens when the reader sees a line starting with an identifier followed by Let's take a (slightly messy) example. Try to quickly count how many Messages are in the following sample:
If you're in camp 1, you likely quickly scanned for I was always in camp 2, and it made me struggle to see the value of enforced Anyway, the reason I'm bringing it up is that in the current proposal, you relax the indentation rules around a different concept. One, that is not aligned with my human reading patterns despite several months of working with From the extreme examples you provided:
So, what did I learn about my processing? I learned that in order to mimic it in the syntax, we could say that a
While the logic of this proposal would change, the outcome would change only in a couple extreme cases:
As for caps I know my comment is long, but the proposal alteration is not that significant. Just instead of relax the indentation requirement for everything other than text content we'd use relax the indentation requirement for everything except of identifier-start. wdyt? |
Thanks for sharing your thoughts, @zbraniecki! Why do you think that this should be enforced by the grammar, rather than by linting and style guides? I honestly don't suppose anyone will write their FTL the way We can't protect users from their sense of aesthetics (or the lack thereof). If, as a localizer or developer, you want readable translation files, Fluent should give you every tool you need to do so. But you can be a bit sloppy, too, and things should mostly work, too. That's the Tolerance design principle at work.
This is much harder to implement in practice. Or at least I'm not sure how to go about it. The way I'm thinking about the relaxation allows the parser to switch into a completely whitespace-insensitive mode as soon as it enters a placeable. The way you propose it, there would still be restrictions that apply depending on what's inside of the placeable. Also, would you allow |
My only point is that error recovery (find the next start of the message) which partially informs the decision here, can (and I argue that it should) be aligned with human readability - because both, the parser and the human are tasked with the same task - "find the start of the message". And what we're trying to do here is find what we have to forbid in order for that task to be easy/possible. As I said, I'm not interested in blocking your proposal - just provided an alternative. :) I'm happy to go with your approach. |
Thanks, @zbraniecki. I went ahead and merged the PR. |
This is a follow-up to #42. I'd like to go further and relax the indentation requirement for everything other than text content. This includes attribute and variant keys as well as expressions.
This doesn't mean that serializers would stop indenting message bodies for readability. We'll still need to define the style guidelines for linting FTL files in #27.
Thanks to #63 this change shouldn't hinder parsers' ability to recover at the next nearest message definition.
A few canonical examples of what would become possible:
And a few extreme ones (please don't write your FTL this way):
The goal is not to encourage people to write FTL like the above but rather, to accept as much input as possible while being as forgiving as possible.
The text was updated successfully, but these errors were encountered: