doc/ref/spec.md: introduction of value aliases

Also:
- removes a deprecated example
- simplifies the definition of AliasExpr

Change-Id: I4f6e389146850102c21fcc9fd75f8bd59daa07df
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9684
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/doc/ref/spec.md b/doc/ref/spec.md
index 72c6416..f0e968c 100644
--- a/doc/ref/spec.md
+++ b/doc/ref/spec.md
@@ -1163,7 +1163,7 @@
 Declaration     = Field | Ellipsis | Embedding | LetClause | attribute .
 Ellipsis        = "..." [ Expression ] .
 Embedding       = Comprehension | AliasExpr .
-Field           = Label ":" { Label ":" } Expression { attribute } .
+Field           = Label ":" { Label ":" } AliasExpr { attribute } .
 Label           = [ identifier "=" ] LabelExpr .
 LabelExpr       = LabelName [ "?" ] | "[" AliasExpr "]" .
 LabelName       = identifier | simple_string_lit  .
@@ -1472,7 +1472,7 @@
 The name of an alias must be unique within its scope.
 
 ```
-AliasExpr  = Expression | identifier "=" Expression .
+AliasExpr  = [ identifier "=" ] Expression .
 ```
 
 Aliases can appear in several positions:
@@ -1492,6 +1492,10 @@
 - for optional fields (`foo?: bar` and `[foo]: bar`),
   the bound identifier is only visible within the field value (`bar`).
 
+Before a value (`foo: X=x`)
+
+- binds the identifier to the value it precedes within the scope of that value.
+
 Inside a bracketed label (`[X=expr]: value`):
 
 - binds the identifier to the the concrete label that matches `expr`
@@ -1508,14 +1512,14 @@
 -->
 
 ```
-// An alias declaration
-Alias = 3
-a: Alias  // 3
-
 // A field alias
 foo: X  // 4
 X="not an identifier": 4
 
+// A value alias
+foo: X={x: X.a}
+bar: foo & {a: 1}  // {a: 1, x: 1}
+
 // A label alias
 [Y=string]: { name: Y }
 foo: { value: 1 } // outputs: foo: { name: "foo", value: 1 }