doc/ref: a few small changes to the spec
Operators are reordered and the `%`, which was inadvertently
left out was added.
The Preference production is removed. Just adopting the stance
of the implementation that it is a unary operator.
Change-Id: I677c6dad1b7055ed9da8c5537b31ddb10999202a
diff --git a/doc/ref/spec.md b/doc/ref/spec.md
index deabfbc..a211238 100644
--- a/doc/ref/spec.md
+++ b/doc/ref/spec.md
@@ -269,11 +269,11 @@
The following character sequences represent operators and punctuation:
```
-+ & && == != ( )
-- | || < <= [ ]
-* : ! > >= { }
-/ ; = ... .. .
-div mod quo rem _|_ <- ,
++ div && == != ( )
+- mod || < <= [ ]
+* quo ! > >= { }
+/ rem & : <- ; ,
+% _|_ | = ... .. .
```
<!-- :: for "is-a" definitions -->
@@ -631,7 +631,7 @@
#### Default values
One or more values in a disjunction can be _marked_
-by prefixing it with a `*` ([`Preference`](#Primary-expressions)).
+by prefixing it with a `*` ([a unary expression](#Operators)).
A bottom value cannot be marked.
When a marked value is unified, the result is also marked.
(When unification results in a single value,
@@ -1006,14 +1006,14 @@
Lists can be thought of as structs:
```
-List: null | {
+List: *null | {
Elem: _
Tail: List
}
```
For closed lists, `Tail` is `null` for the last element, for open lists it is
-`null | List`.
+`*null | List`, defaulting to the shortest variant.
For instance, the open list [ 1, 2, ... ] can be represented as:
```
open: List & { Elem: 1, Tail: { Elem: 2 } }
@@ -1212,13 +1212,11 @@
```
PrimaryExpr =
Operand |
- Preference |
PrimaryExpr Selector |
PrimaryExpr Index |
PrimaryExpr Slice |
PrimaryExpr Arguments .
-Preference = "*" Expression
Selector = "." identifier .
Index = "[" Expression "]" .
Slice = "[" [ Expression ] ":" [ Expression ] "]"
@@ -1386,7 +1384,7 @@
add_op = "+" | "-" .
mul_op = "*" | "/" | "%" | "div" | "mod" | "quo" | "rem" .
-unary_op = "+" | "-" | "!" .
+unary_op = "+" | "-" | "!" | "*" .
```
<!-- TODO: consider adding unary_op: "<" | "<=" | ">" | ">=" -->
@@ -1447,9 +1445,9 @@
`div`, `mod`, `quo`, and `rem` only apply to integer types.
```
-+ sum integers, floats, lists, strings
++ sum integers, floats, lists, strings, bytes
- difference integers, floats
-* product integers, floats, lists, strings
+* product integers, floats, lists, strings, bytes
/ quotient floats
% remainder floats
div division integers
@@ -1458,6 +1456,7 @@
rem remainder integers
```
+
#### Integer operators
For two integer values `x` and `y`,
@@ -1527,8 +1526,7 @@
a + b
```
will produce an open list if `b` is open.
-If list `a` is open, only the existing elements will be involved in the
-concatenation.
+If list `a` is open, its default value, the shortest variant, is selected.
```
[ 1, 2 ] + [ 3, 4 ] // [ 1, 2, 3, 4 ]
@@ -1591,8 +1589,19 @@
<!-- TODO(mpvl): should we disallow multiplication with a range?
If so, how does one specify a list with a range of possible lengths? -->
-<!-- jba: Clarify the allowed values for the non-list operand. And must that be
-the left operand? -->
+
+<!-- TODO(mpvl): should we allow multiplication with a range?
+If so, how does one specify a list with a range of possible lengths?
+
+Suggestion from jba:
+Multiplication should distribute over disjunction,
+so int(1)..int(3) * [x] = [x] | [x, x] | [x, x, x].
+The hard part is figuring out what 1..3 * [x] means,
+since 1..3 includes many floats.
+(mpvl: could constrain arguments to parameter types, but needs to be
+done consistently.)
+-->
+
#### String operators