From a6b546fe3116095761b35976a231f64d28082934 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 20 Oct 2008 11:46:40 -0700 Subject: [PATCH] - 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 --- doc/go_spec.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/go_spec.txt b/doc/go_spec.txt index b8271ee8136..ed279ce7e20 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