-
-
Notifications
You must be signed in to change notification settings - Fork 36
Compare three remaining options (draft) #496
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4248630
Compare three remaining options (draft)
aphillips 0d44ddf
Update exploration/syntax-exploration-2.md
aphillips cbdefb6
Update exploration/syntax-exploration-2.md
aphillips 2d208a2
Update exploration/syntax-exploration-2.md
aphillips 534f31f
Update exploration/syntax-exploration-2.md
aphillips d3d65c7
Update exploration/syntax-exploration-2.md
aphillips 7c58a86
Update exploration/syntax-exploration-2.md
aphillips 292e8df
Update exploration/syntax-exploration-2.md
aphillips 01075b4
Update exploration/syntax-exploration-2.md
aphillips 41a841c
Update exploration/syntax-exploration-2.md
aphillips 2f7517b
Add comparison matrix (first draft) and sigils section
aphillips da4ea08
Fix typos
aphillips 57aa008
Flesh out sigils to make complete.
aphillips c27c0e2
Update sigil table, adding \
eemeli b7a74ec
Update exploration/syntax-exploration-2.md
aphillips 9c00f18
Add section about sigiling and whitespace
aphillips be18e7d
Merge remote-tracking branch 'upstream/main' into aphillips-syntax-ex…
aphillips 8ec13f3
Changes to 3a based on slack conversation threads
aphillips afeea3f
Change comparison table to be more neutral about unquoted pattern
aphillips 27565fd
Update exploration/syntax-exploration-2.md
aphillips 2207a63
Update exploration/syntax-exploration-2.md
aphillips 6315c30
Update exploration/syntax-exploration-2.md
aphillips 74e610b
Apply suggestions from code review
aphillips File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
# Syntax Exploration v2 | ||
|
||
In the 2023-10-16 teleconference, we narrowed the options being considered for text-mode syntax to "1a", "2a", and "3a". | ||
Each of these syntax candidates has been adjusted based on our conversation. | ||
|
||
One open issue, separately considered here, is the use of an additional sigil for some of the syntaxes. | ||
We have generally used `#` as the placeholder for this sigil in the previous iteration. | ||
|
||
|
||
## Comparison Matrix | ||
|
||
> [!Note] | ||
> The `+` and `-` values do not connote a value judgment about a given candidate. | ||
|
||
| Option | Description | Doesn’t Nest {} | Doesn’t Need More Escapes | Allows Unquoted Pattern | Counted {} works | Multiple Expression Syntaxes | | ||
| :----- | :------------------------------------------------------------- | :-------------- | :------------------------ | :----------------------------- | :--------------- | :------------ | | ||
| 1a | Invert for text mode, distinguish statements from placeholders | - | + | + | + | - | | ||
| 2a | Text first, current syntax for complex messages | - | + | - | - | + | | ||
| 3a | Use sigils for code mode | + | - | + | + | + | | ||
|
||
|
||
## Candidates | ||
|
||
### Candidate 1a | ||
|
||
**Description:** Invert for Text Mode, distinguish statements from placeholders | ||
|
||
- Placeholders and expressions use `{`/`}`: | ||
> `{$var}`, `{unquoted}`, `{|quoted|}`, `{$var :function}` | ||
- Non-placeholders use `{#`/`}`: | ||
> `{#input $user}`, `{#local $var=$foo :expr}`, `{#match {$foo}}`, `{#when * *}` | ||
|
||
The use of `#` as the sigil is intentional here. | ||
This sigil might be replaced, but does not require additional escaping, as code is enclosed in `{`/`}`. | ||
Note that the `#` sigil might also be considered to be part of the keyword, e.g. `#when`, `#local` vs. | ||
allowing whitespace to appear between them. | ||
|
||
Patterns in this syntax are generally unquoted, | ||
but MAY be quoted with the 2023-10-09 consensus `{{`/`}}` quotes. | ||
|
||
ASCII whitespace trimming is assumed, but is a hot topic. | ||
|
||
**Examples** | ||
``` | ||
Hello world! | ||
``` | ||
``` | ||
Hello {$user} | ||
``` | ||
``` | ||
{#input $user :person type=informal} | ||
Hello {$user} | ||
|
||
{#input $user :person type=informal}Hello {$user} | ||
``` | ||
``` | ||
{#input $var :function option=value} | ||
{#local $foo = $bar :function option=value} | ||
Hello {$var}, you have a {$foo} | ||
|
||
{#input $var :function option=value}{#local $foo = $bar :function option=value}Hello {$var}, you have a {$foo} | ||
``` | ||
``` | ||
{#match {$foo}} | ||
{#when foo} Hello {$foo} you have a {$var} | ||
{#when *} {$foo} hello you have a {$var} | ||
|
||
{#match {$foo}}{#when foo}Hello {$foo} you have a {$var}{#when *}{$foo} hello you have a {$var} | ||
``` | ||
``` | ||
{#match {$foo :function option=value} {$bar :function option=value}} | ||
{#when a b} {{ {$foo} is {$bar} }} | ||
{#when x y} {{ {$foo} is {$bar} }} | ||
{#when * *} {| |}{$foo} is {$bar}{| |} | ||
|
||
{#match {$foo :function option=value}{$bar :function option=value}}{#when a b}{{ {$foo} is {$bar} }}{#when x y}{{ {$foo} is {$bar} }}{#when * *}{| |}{$foo} is {$bar}{| |} | ||
``` | ||
|
||
### Candidate 2a | ||
|
||
**Description**: Text First, Current Syntax for "Complex" Messages | ||
|
||
Starts in text mode, but switches to the current "code-mode" syntax for any message containing declarations or selectors. | ||
|
||
- "Simple" messages (lacking declarations or selectors) are unquoted patterns. | ||
- Patterns with declarations (`input`, `local`), selectors (`match`/`when`) or both quote all patterns. | ||
- Pattern whitespace is always significant. | ||
Note that "pattern whitespace" is only that whitespace that appears inside the quoting `{`/`}` | ||
for quoted patterns. | ||
|
||
The use of `{# ... #}` to represent the starting and ending code-mode sigils is **_not_** final. | ||
**_Do not fixate on the specific character sequence when choosing (or not) this design._** | ||
|
||
**Examples** | ||
``` | ||
Hello world! | ||
``` | ||
``` | ||
Hello {$user} | ||
``` | ||
``` | ||
{# | ||
input {$user :function option=value} | ||
{Hello {$user}} | ||
#} | ||
|
||
{#input {$user :function option=value}{Hello {$user}}#} | ||
``` | ||
``` | ||
{# | ||
input {$var :function option=value} | ||
local $foo = {$bar :function option=value} | ||
{Hello {$var}, you have a {$foo}} | ||
#} | ||
|
||
{#input {$var :function option=value}local $foo = {$bar :function option=value}{Hello {$var}, you have a {$foo}}#} | ||
``` | ||
``` | ||
{# | ||
match {$foo} | ||
when foo {Hello {$foo} you have a {$var}} | ||
when * {{$foo} hello you have a {$var}} | ||
#} | ||
|
||
{#match {$foo}when foo{Hello {$foo} you have a {$var}}when *{{$foo} hello you have a {$var}}#} | ||
``` | ||
|
||
``` | ||
{# | ||
match {$foo :function option=value} {$bar :function option=value} | ||
when a b { {$foo} is {$bar} } | ||
when x y { {$foo} is {$bar} } | ||
when * * { {$foo} is {$bar} } | ||
#} | ||
|
||
{#match {$foo :function option=value}{$bar :function option=value}when a b{ {$foo} is {$bar} }when x y{ {$foo} is {$bar} }when * *{ {$foo} is {$bar} }#} | ||
``` | ||
|
||
### Candidate 3a | ||
|
||
**Description:** Use sigils for code mode | ||
|
||
- Starts in text mode. | ||
- Uses a sigil for code statements. | ||
- Requires the code-mode sigil to be escaped in **_unquoted_** patterns. | ||
- Quoted patterns do not require this sigil to be escaped. | ||
- Note that decisions about auto-trimming affect the escaping situation. | ||
If quoting the pattern is required, no additional escapes are needed. | ||
- Expressions use `{`/`}`: | ||
> `{$var}`, `{unquoted}`, `{|quoted|}`, `{$var :function}` | ||
- There is only one expression syntax, which applies to all expressions. | ||
- Note: placeholders are expressions. | ||
- Variants use a double-sigil `%[` at the start and close the list of `keys` | ||
with a `]`. | ||
- The sequence `%[` must be escaped in unquoted patterns. | ||
|
||
Patterns in this syntax are generally unquoted, | ||
but MAY be quoted with the 2023-10-09 consensus `{{`/`}}` quotes. | ||
|
||
Patterns lacking declarations, selectors, or both, are **_not_** auto-trimmed. | ||
Whitespace in quoted patterns is significant. | ||
Whitespace in unquoted patterns may or may not be significant (hot topic). | ||
|
||
``` | ||
Hello world! | ||
``` | ||
``` | ||
Hello {$user}! | ||
``` | ||
``` | ||
%input {$var :function option=value} | ||
Hello {$var} | ||
|
||
%input {$var :function option=value}Hello {$var} | ||
``` | ||
``` | ||
%input {$var :function option=value} | ||
%local $foo = {$bar :function option=value} | ||
Hello {$var}, you have a {$foo} | ||
|
||
%input {$var :function option=value}%local $foo = {$bar :function option=value}Hello {$var}, you have a {$foo} | ||
``` | ||
``` | ||
%match {$foo} | ||
%[foo] Hello {$foo} you have a {$var} | ||
%[*] {$foo} hello you have a {$var} | ||
|
||
%match {$foo}%[foo] Hello {$foo} you have a {$var}%[*] {$foo} hello you have a {$var} | ||
``` | ||
|
||
``` | ||
%match {$foo :function option=value} {$bar :function option=value} | ||
%[a b] {{ {$foo} is {$bar} }} | ||
%[x y] {||} {$foo} is {$bar} {||} | ||
%[* *] {| |}{$foo} is {$bar}{| |} | ||
|
||
%match {$foo :function option=value} {$bar :function option=value}%[a b] {{ {$foo} is {$bar} }}%[x y] {||} {$foo} is {$bar} {||}%[* *] {| |}{$foo} is {$bar}{| |} | ||
``` | ||
|
||
## Whitespace and Pattern Boundaries | ||
|
||
One key consideration for the above options is distinguishing the boundary between | ||
the end of a _pattern_ and the start of a _variant_ (`when` clause). | ||
This was not an issue in the code-mode syntax because the patterns were always delimited ("quoted"). | ||
|
||
> [*Note] | ||
> This type of syntax is only needed if patterns are not quoted. | ||
> The "hot debate" in our 2023-10-16 teleconference was between "WYSIWYG" | ||
> no-whitespace-trimming supporters and current WG consensus. | ||
> For current consensus and discussion of whitespace design see [here](pattern-exterior-whitespace.md) | ||
|
||
- Candidate 1a uses a double sigil `{#` or distinguishing sequence `{#when` to accomplish this. | ||
- Candidate 2a quotes all patterns in code-mode. | ||
- Candidate 3a uses a sigil sequence `%[` to accomplish this | ||
|
||
It is reasonable to think that we might modify this particular part of the syntax | ||
to improve usability. **_Keep in mind the need for single-line authoring._** | ||
|
||
For example: | ||
|
||
>``` | ||
>%match {$foo} | ||
>%%{0} You have no ducks. | ||
>%%{one} You have {$foo} duck. | ||
>%%{*} You have {$foo} ducks. | ||
> | ||
>%match {$foo} | ||
>[[0]] You have no ducks. | ||
>[[one]] You have {$foo} duck. | ||
>[[*]] You have {$foo} duck. | ||
>``` | ||
|
||
## Sigil Candidates | ||
|
||
Some of the above syntaxes require an additional sigil. | ||
|
||
Here are the potential sigils that can be used: | ||
|
||
| Sigil | Positives | Negatives | | ||
|---|---|---| | ||
| `!` | | Means "not" in most programming languages. | | ||
| `@` | Feels like code? | Means "address" in a lot of contexts. Might be used for annotations | | ||
| `#` | Feels like code. Similar to `#define`. | Common in real text. Used for _everything_, in particular comments. | | ||
| `%` | Feels like code. Used by some templating languages. | Common in real text. | | ||
| `^` | | Uncommon choice. Harder to see. | | ||
| `&` | | Used in a lot of escapes, notably HTML. | | ||
| `+` | | Looks like an operator. | | ||
| `_` | Feels like code. | Looks like a name prefix. Hard to see. | | ||
| `\|` | | Already used in our syntax for a diff purpose. Weird. | | ||
| `\` | Feels like code. Already escaped in patterns. | May require escaping (doubling) in host formats. | | ||
| `>` | | Has meaning in markup. Wants to pair with `<`. | | ||
| `<` | | Has meaning in markup. Wants to pair with `>`. | | ||
| `?` | | Looks like `?` operator. Looks like a variable. Very common in real text. | | ||
| `::` | | Common in real text. Looks like part of a ternary operator. | | ||
| `;` | Can't think of any. | Looks like a statement close. | | ||
| `~` | | Looks like an operator. | | ||
| `*` | | Looks like a wildcard. Already used by the syntax. | | ||
| `-` | | Too common in normal text. | | ||
| `=` | | Looks like an operator. Already used by the syntax. | | ||
| `[` | | Enclosing punctuation. | | ||
| `]` | | Enclosing punctuation. | | ||
| `.` | | Too common in normal text. Used by other syntaxes | | ||
| `,` | | Too common in normal text. Not code-like? | | ||
| <code>`</code> | | Quote mark. | | ||
| `'` | | Quote mark. | | ||
| `"` | | Quote mark. | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do "single-line authoring" mean that:
or
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the former. Single-line authoring means that syntactically-allowed-but-not-required whitespace is removed. It is shorthand for: many people will author messages in a resource format in which the message is a string with file-local escaping. Think about that in addition to the pretty formatting we use in examples like this:
That might be single line as:
(Note that I have trimmed whitespace off of the pattern in the single-line example.)