@@ -83,7 +83,9 @@ let ref_2 = in arena { value_expression };
83
83
84
84
# Detailed design
85
85
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.
87
89
88
90
` EXPR <- EXPR ` is parsed into an AST form that is desugared in much
89
91
the same way that ` in EXPR { BLOCK } ` or ` box (EXPR) EXPR ` are
@@ -158,6 +160,40 @@ let ref_1 = in arena <- value_expression;
158
160
let ref_2 = in arena <- value_expression ;
159
161
```
160
162
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
+ This, however introduces an inconsistency in parsing between ` let x = ` and
175
+ ` x = ` : ` let x = (y <- z) ` but ` (x = z) <- y ` .
176
+
177
+ 2 . Same as assignment and binop-assignment:
178
+
179
+ ` x = y <- z = a <- b = c = d <- e <- f ` parses as
180
+ ` x = (y <- (z = (a <- (b = (c = (d <- (e <- f))))))) ` . This is so far
181
+ the easiest option to implement in the compiler.
182
+
183
+ 3 . More than assignment and binop-assignment, but less than any other operator:
184
+
185
+ This is what currently this RFC proposes. This allows for various
186
+ expressions involving equality symbols and ` <- ` to be parsed reasonably and
187
+ consistently. For example ` x = y <- z += a <- b <- c ` would get parsed as `x
188
+ = ((y <- z) += (a <- (b <- c)))`.
189
+
190
+ 4 . More than any operator:
191
+
192
+ This is not a terribly interesting one, but still an option. Works well if
193
+ we want to force people enclose both sides of the operator into parentheses
194
+ most of the time. This option would get ` x <- y <- z * a ` parsed as `(x <-
195
+ (y <- z)) * a`.
196
+
161
197
# Unresolved questions
162
198
163
199
None
0 commit comments