-
Notifications
You must be signed in to change notification settings - Fork 45
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
New value type: Variant List #102
Comments
There still remains an inconsistency: a # This wouldn't be allowed.
key =
Foo Bar {
*[name] Variant
} Baz But because they would be legal as values of other variants, this would be OK: # This is OK.
key =
Foo Bar { $num ->
*[other] {
*[name] Variant
}
} Baz To solve this, we'd need to make the variants in I'm not sure if such distinction is necessary nor if it's worth the effort and the increase of complexity. From the use-cases point of view, a simple |
There are aspects here that are not about if we do it or not, but where. Is it Syntax or Semantics that are statically checked. I'd like to see both variants (pun intended), and see which of the two is easier to learn. We'll need to document both, one will be solely in the syntax, the other will be split between syntax and semantics. |
I like this proposal. I see a potential in the VariantList in the future so I'm happy to see it being formalized. |
Taking a question about intent here instead of the PR: @stasm , I see the semantically correct usage of I've filed #130 for private terms, which would be a way for a localization to hack around the lack of a Term. But I also don't like the idea of making a work-around that much work to use that in a context like: A developer uses a message reference, but the string as is doesn't work as is in a particular locale. Say, because literal quoting isn't a thing in that language. To work around it, the locale would either drop the message ref, or add variants to the message. Or add a private term as proposed in #130. Maybe this is more of a documentation problem than anything else? |
I think we talked about forbidding |
@Pike On Friday we talked about allowing Because of this added complexity, I suggest we move this entire feature ( |
sgtm. |
We currently allow Select Expressions to have a null selector. This is mostly useful in Terms to define facets of the term's value:
The grammar defines the above syntax as:
Variants defined this way can be retrieved inside of Placeable with the
-term[variant name]
syntax. The runtime checks if the term's value is a pattern with a single element: a placeable which is a selector-less select expression. If the conditions are met, the variant is retrieved successfully.The fact that we need this complex runtime check indicates to me that we're abusing Patterns for a logic-less (no selector) store for variants.
I'd like to make the design of Variant List more explicit by making them a new value type. Grammar-wise, values of Messages, Terms and Variants could either be Patterns or Variant Lists. Value List would not be expressions. Static analysis tools can then very easily tell when Variant Lists are mis-used: they shouldn't appear in Message at all, and they should only be nested inside of other Variant Lists.
The FTL snippet above would parse as follows:
The text was updated successfully, but these errors were encountered: