Skip to content

Commit

Permalink
Some updates from 2023-10-09 call
Browse files Browse the repository at this point in the history
  • Loading branch information
aphillips authored Oct 9, 2023
1 parent 9d8af26 commit 38da6b1
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions exploration/0487-whitespace.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pattern Exterior Whitespace

Status: **Proposed**
Status: **Accepted**

<details>
<summary>Metadata</summary>
Expand All @@ -20,7 +20,7 @@ Status: **Proposed**
_What is this proposal trying to achieve?_

The WG is discussing how to handle "pattern exterior" whitespace,
which is ASCII whitespace (tab, newline, or U+0020) that is **_part_** of the pattern
which is ASCII whitespace (tab, CR, LF, or U+0020) that is **_part_** of the pattern
and occurs at the start or end of the pattern.

## Background
Expand Down Expand Up @@ -70,8 +70,12 @@ _What prior decisions and existing conditions limit the possible design?_

_Describe the proposed solution. Consider syntax, formatting, errors, registry, tooling, interchange._

Trim all whitespace.
Document solutions (1) and (2) below.
- Patterns MAY be quoted using solution 4
- User can quote whitespace using solutions 1 and 2

Still being discussed:
- Whether unquoted "simple" patterns are trimmed.
This will be dealt with in the syntax spec.

## Alternatives Considered

Expand All @@ -92,104 +96,106 @@ Note that (1) and (2) will be valid options regardless of what else we do.

---

#### Examples of the above with newlines and tabs in a variant
#### Examples of the above in a selector

1. Quoted literals

```
#when [*] {|
|}Newline and tab quoted
#match {$user}
#when [*] {| |}Hello {$user}{| |}
```

2. Empty literals

```
#when [*] {||}
Newline and tab after empty literal
#match {$user}
#when [*] {||} Hello {$user} {||}
```

3. {Quoted} pattern

```
#when [*] {
Newline and tab inside pattern}
#match {$user}
#when [*] { Hello {$user} }
```

4. {{Quoted}} pattern

```
#when [*] {{
Newline and tab inside pattern}}
#match {$user}
#when [*] {{ Hello {$user} }}
```

5. Quote exterior spaces

```
#when [*] \
\ Newline and tab escaped
#match {$user}
#when [*] \ \ Hello {$user}\ \
```

6. Quote outside space

```
#when [*] \
Newline escaped and tab naked
#match {$user}
#when [*] \ Hello {$user} \
```

7. No trimming

```
#when [*]
Newline and tab are significant whitespace
#match {$user}
#when [*] Hello {$user}
```

#### Examples of the above in a selector
#### Examples of the above with newlines and tabs in a variant

1. Quoted literals

```
#match {$user}
#when [*] {| |}Hello {$user}{| |}
#when [*] {|
|}Newline and tab quoted
```

2. Empty literals

```
#match {$user}
#when [*] {||} Hello {$user} {||}
#when [*] {||}
Newline and tab after empty literal
```

3. {Quoted} pattern

```
#match {$user}
#when [*] { Hello {$user} }
#when [*] {
Newline and tab inside pattern}
```

4. {{Quoted}} pattern

```
#match {$user}
#when [*] {{ Hello {$user} }}
#when [*] {{
Newline and tab inside pattern}}
```

5. Quote exterior spaces

```
#match {$user}
#when [*] \ \ Hello {$user}\ \
#when [*] \
\ Newline and tab escaped
```

6. Quote outside space

```
#match {$user}
#when [*] \ Hello {$user} \
#when [*] \
Newline escaped and tab naked
```

7. No trimming

```
#match {$user}
#when [*] Hello {$user}
#when [*]
Newline and tab are significant whitespace
```


0 comments on commit 38da6b1

Please sign in to comment.