diff options
| author | Robert Griesemer <gri@golang.org> | 2008-10-20 11:46:40 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2008-10-20 11:46:40 -0700 |
| commit | 0f3d573d0d6eca115d94d9768d608017b070d3fe (patch) | |
| tree | fd0eed5b87b6c9e9c1fb8118349e0281d23c5a2f | |
| parent | e58cb05d12a9df5e670b87d66e7b9c71a3acbe54 (diff) | |
| download | golang-0f3d573d0d6eca115d94d9768d608017b070d3fe.tar.gz | |
- be even more explicit about ideal number conversion in expressions
- added a note with respect the difference of semantics of *p++ in Go vs C
R=r
DELTA=14 (6 added, 2 deleted, 6 changed)
OCL=17455
CL=17457
| -rw-r--r-- | doc/go_spec.txt | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/doc/go_spec.txt b/doc/go_spec.txt index b8271ee81..ed279ce7e 100644 --- a/doc/go_spec.txt +++ b/doc/go_spec.txt @@ -4,7 +4,7 @@ The Go Programming Language Specification (DRAFT) Robert Griesemer, Rob Pike, Ken Thompson ---- -(October 15, 2008) +(October 20, 2008) This document is a semi-formal specification of the Go systems @@ -1135,7 +1135,7 @@ other field within the struct. Fields and methods (§Method declarations) of an anonymous field become directly accessible as fields and methods of the struct without the need to provide the -type name of the respective anonymous field (§TODO). +type name of the respective anonymous field (§Selectors). Forward declaration: A struct type consisting of only the reserved word "struct" may be used in @@ -1709,17 +1709,21 @@ Operators combine operands into expressions. The operand types in binary operations must be equal, with the following exceptions: - - The right operand in a shift operation must be - an unsigned int (§Arithmetic operators). - - - Otherwise, ideal number operands are - converted to match the type of the other operand (§Expression). + - If one operand has numeric type and the other operand is + an ideal number, the ideal number is converted to match the type of + the other operand (§Expression). - If both operands are ideal numbers, the conversion is to ideal floats if one of the operands is an ideal float (relevant for "/" and "%"). + - The right operand in a shift operation must be always be an unsigned int + (or an ideal number that can be safely converted into an unsigned int) + (§Arithmetic operators). + Unary operators have the highest precedence. They are evaluated from -right to left. +right to left. Note that "++" and "--" are outside the unary operator +hierachy (they are statements) and they apply to the operand on the left. +Specifically, "*p++" means "(*p)++" in Go (as opposed to "*(p++)" in C). There are six precedence levels for binary operators: multiplication operators bind strongest, followed by addition |
