diff options
Diffstat (limited to 'chapter17/README.md')
| -rw-r--r-- | chapter17/README.md | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/chapter17/README.md b/chapter17/README.md index 6c70f022..5a7f48d3 100644 --- a/chapter17/README.md +++ b/chapter17/README.md @@ -6,12 +6,33 @@ Allow `arg++` and `arg--` with the usual meanings; the value is updated and the expression is the pre-update value. Greedy match is used so `arg---arg` parses as `(arg--)-arg`. +Also allows `s.fld++` and `ary[idx]++`, and their `--` variants. + +# var & val + +`var` can be used in the `type` position to indicate a "variable" (mutable +value), whose type will be inferred from the initalizing expression. + +`val` is the same as `var`, except its a "value" (not mutable). + +The inferred value is the `glb` of the peephole type, which means `var` and +`val` will not infer types like `u8` or `f32`, instead inferring `int` and +`flt` respectively. Struct types will always infer as nullable, so e.g. + +`var s = new S;` + +infers as + +`S s? = new S;` + + + -var/val invert ! C++-style for-loop for-interator - +trinary +switch |
