Skip to content

Commit 1f0fb30

Browse files
committed
Amend RFC1228 with operator fixity
1 parent f404718 commit 1f0fb30

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

text/1228-placement-left-arrow.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ let ref_2 = in arena { value_expression };
8383

8484
# Detailed design
8585

86-
Extend the parser to parse `EXPR <- EXPR`.
86+
Extend the parser to parse `EXPR <- EXPR`. The left arrow operator is
87+
right-associative and has precedence higher than assignment and
88+
binop-assignment, but lower than other binary operators.
8789

8890
`EXPR <- EXPR` is parsed into an AST form that is desugared in much
8991
the same way that `in EXPR { BLOCK }` or `box (EXPR) EXPR` are
@@ -158,6 +160,38 @@ let ref_1 = in arena <- value_expression;
158160
let ref_2 = in arena <- value_expression;
159161
```
160162

163+
## Fixity
164+
165+
Finally, fixity of this operator may be defined to be anything from being less
166+
than assignment/binop-assignment (set of right associative operators with
167+
lowest precedence) to highest in the language. The most prominent choices are:
168+
169+
1. Less than assignment:
170+
171+
Assuming `()` never becomes a `Placer`, this resolves a pretty common
172+
complaint that a statement such as `x = y <- z` is not clear or readable
173+
by forcing the programmer to write `x = (y <- z)` for code to typecheck.
174+
175+
2. Same as assignment and binop-assignment:
176+
177+
`x = y <- z = a <- b = c = d <- e <- f` parses as
178+
`x = (y <- (z = (a <- (b = (c = (d <- (e <- f)))))))`. This is so far
179+
the easiest option to implement in the compiler.
180+
181+
3. More than assignment and binop-assignment, but less than any other operator:
182+
183+
This is what currently this RFC proposes. This allows for various
184+
expressions involving equality symbol to be parsed reasonably and
185+
consistently. For example `x = y <- z += a <- b <- c` would get parsed as `x
186+
= ((y <- z) += (a <- (b <- c)))`.
187+
188+
4. More than any operator:
189+
190+
This is not a terribly interesting one, but still an option. Works well if
191+
we want to force people enclose both sides of the operator into parentheses
192+
most of the time. This option would get `x <- y <- z * a` parsed as `(x <-
193+
(y <- z)) * a`.
194+
161195
# Unresolved questions
162196

163197
None

0 commit comments

Comments
 (0)