-
-
Notifications
You must be signed in to change notification settings - Fork 36
Variants: should variant keys be delimited, too? #253
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
Comments migrated from the slidesSlides comment, Addison Phillips (@aphillips), 8:21 AM Apr 21 I agree with the bullet points below. I think those issues make this close to a non-starter for me. The problems with whitespace management and getting translators/tools to do the right things here seem like a huge distraction. Question: is there a reason not to delimit both keys and patterns? In my prototype I delimit keys with Slides comment, Eemeli Aro (@eemeli), 9:29 AM Apr 21 Too much markup is the reason we didn't consider this to any great extent: Once one of the two is delimited, the other one doesn't need to be. We are not proposing "quotes" as delimiters as our sense is that they're even more common than [brackets], leading to even more escaping. Also, many container formats (such as JSON) use "quotes" as their own value delimiters, meaning that the in-message quotes would themselves need to be escaped. As with all things MF2, everything is of course still possible. If/once we pick one of the options given here as a starting point, it should become much easier to talk about individual fixes/improvements to that. Slides comment, Elango Cheran (@echeran), 12:53 PM Apr 21 +1 to Addison's question about delimiting both keys and patterns in a selection message. |
Related to #257 |
In a message with selectors, there are basically
There can be multiple selectors. It should be visually obvious what's what. Therefore, the list of selector specifications should be delimited, as should be each list of key literals. For such lists, developers will find Inside a list of key literals, each literal may or may not need delimiters. We should allow literals with spaces, which means that we need to at least allow delimited key literals. And assuming that the literals are space-separated, it would be best to use per-literal delimiters that visually show the start & end of each literal. Between that and trying to avoid |
Do we need delimiters enclosing each/some of the components that @markusicu listed, or perhaps separators between them? Let's consider the following message written in the current
@markusicu proposed the following syntax:
(#255 is tightly coupled with this issue, unfortunately.) Would it help if we separated selectors and keys, rather than delimit them? For example:
|
Or perhaps even put the equals sign
|
Separators feel more natural, eg: {$host :gender}? Perhaps even {$host :gender}? If we wanted to make it more distinctive when single line, then a separator between keys+variant might be useful. {$host :gender}? {$count :plural}? @ female, 1, [{$hostName} created her party of one.] @ female, *, [{$hostName} created her party of {$count}.] |
This seems to be expanding into multiple sub-questions...
|
++100 to this. Something at the start would be a lot more readable for the user (and probably easier to parse) I would be fine with harder to parse if it makes life better for the human user. As a human reading:
is friendlier than
In the first case I can instantly see "ah, two selectors!" |
I'm happy with the approach of syntax that groups the selectors together,
and groups the keys together, such as:
[selectors]
[keyList1] {message}
[keyList2] {message}
...
I think it is quite clear what is going on. And for readability, the writer
would always have the option to make a variable definition out of a long
selector, eg
$count = {$foo :number offset=2 rounding=up minFractionalDigits=2
maxFractionalDigits=4}
$gender = {$bar :gender}
[$count $gender]
[one female] {message-variant1}
[one male] {message-variant2}
[one *] {message-variant3}
One could have different syntax for the selectors vs the keys for clarity,
eg the following, but I'm not sure that is necessary.
$count = {$foo :number offset=2 rounding=up minFractionalDigits=2
maxFractionalDigits=4}
$gender = {$bar :gender}
[[$count $gender]]
[one female] {message-variant1}
[one male] {message-variant2}
[one *] {message-variant3}
I'm not fond of the postfix notation, because as Mihai notes, you have to
read into the line to see what the role is. If people really couldn't live
with a grouping notation like [...], a prefix notation would be better than
a postfix notation.
And I'm not fond of ?, because a lot of people will associate it with
either regex notation or the conditional notations like x = a ? b : c;
I could also live with a separator character before the selectors, and a
separator character before each list of keys: either the same for each or
different, eg. @ and : below (though I have no particular attachment to
those two choices).
$count = {$foo :number offset=2 rounding=up minFractionalDigits=2
maxFractionalDigits=4}
$gender = {$bar :gender}
@$count $gender
: one female{message-variant1}
: one male{message-variant2}
: one * {message-variant3}
In the literal text in the message variants, we really need to minimize the
number of characters that have to be escaped, and try to use syntax
characters that are very infrequently used in real messages. So {, }, and \
are great. Outside of literal text in message variants, there is more
freedom.
But I'm happy with just going with Markus's suggestion for [...]
…On Wed, Jun 8, 2022 at 4:32 PM Mihai Nita ***@***.***> wrote:
In particular, the question mark as a suffix is not good. It should be
clear within a character or two whether we are looking at the first or last
selector.
++100 to this.
Something at the start would be a lot more readable for the user (and
probably easier to parse)
I would be fine with harder to parse if it makes life better for the human
user.
As a human reading:
{? $foo :number offset=2 rounding=up minFractionalDigits=2 maxFractionalDigits=4}
{? $bar :gender}
is friendlier than
{$foo :number offset=2 rounding=up minFractionalDigits=2 maxFractionalDigits=4}?
{$bar :gender}?
In the first case I can instantly see "ah, two selectors!"
In the second case I have to scan to the end of possibly long, uneven
lines, maybe with line breaks.
—
Reply to this email directly, view it on GitHub
<#253 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACJLEMDGQXMIESVHOLNAEQ3VOEURBANCNFSM5VWCWTSA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I see the advantages of the |
Closed by #287. |
No description provided.
The text was updated successfully, but these errors were encountered: