doc/ref/spec.md: get rid of list operators
List operators are confusing. For instance,
is the result of [a, ...] + [b, ...] open or close?
What about [a] + [b, ...]? And so on.
With the current semantics of comprehensions, they
are also unnecessary. The above can be written as
[ for x in a {x}, for x in b {x} ].
Though more verbose, it is very clear here that
regardless of whether a and b are open or closed
the result is always closed.
With the query extension, this can also be written
more succinctly, like `[ a.[_], b.[_] ]` or perhaps
`[a.*, b.*]`, either case is clearer than using list
operators.
See Issue #165.
In order to move to being able to give backwards
compatiblity guarantees, we propose getting rid of list
addition and multiplication. An automatic rewriter could
rewrite the old use using `list.Repeat` and `list.Concat`,
the latter of which could refer to the spec to indicate
its equivalence to using comprehensions or, later, queries.
Change-Id: I374bfd59775d66d3da9feb28e1940f8bd3c255e8
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8063
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/doc/ref/spec.md b/doc/ref/spec.md
index da62c38..9d5a6cb 100644
--- a/doc/ref/spec.md
+++ b/doc/ref/spec.md
@@ -2196,12 +2196,12 @@
Arithmetic operators apply to numeric values and yield a result of the same type
as the first operand. The four standard arithmetic operators
`(+, -, *, /)` apply to integer and decimal floating-point types;
-`+` and `*` also apply to lists and strings.
+`+` and `*` also apply to strings and bytes.
```
-+ sum integers, floats, lists, strings, bytes
++ sum integers, floats, strings, bytes
- difference integers, floats
-* product integers, floats, lists, strings, bytes
+* product integers, floats, strings, bytes
/ quotient integers, floats
```
@@ -2223,39 +2223,6 @@
-x negation is 0 - x
```
-#### List operators
-
-Lists can be concatenated using the `+` operator.
-Opens list are closed to their default value beforehand.
-
-```
-[ 1, 2 ] + [ 3, 4 ] // [ 1, 2, 3, 4 ]
-[ 1, 2, ... ] + [ 3, 4 ] // [ 1, 2, 3, 4 ]
-[ 1, 2 ] + [ 3, 4, ... ] // [ 1, 2, 3, 4 ]
-```
-
-Lists can be multiplied with a non-negative`int` using the `*` operator
-to create a repeated the list by the indicated number.
-```
-3*[1,2] // [1, 2, 1, 2, 1, 2]
-3*[1, 2, ...] // [1, 2, 1, 2, 1 ,2]
-[byte]*4 // [byte, byte, byte, byte]
-0*[1,2] // []
-```
-
-<!-- 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
Strings can be concatenated using the `+` operator: