diff options
author | Rob Pike <r@golang.org> | 2009-04-14 20:10:49 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-04-14 20:10:49 -0700 |
commit | ac83c543490dd39ef522a07dfbcdfe92d3d01784 (patch) | |
tree | a85254915dd0b68cf3e1a6629a092295bb8e7bb7 | |
parent | e3b84434186d21adfb143104682d26b187082c61 (diff) | |
download | golang-ac83c543490dd39ef522a07dfbcdfe92d3d01784.tar.gz |
add a section about order of evaluation
DELTA=32 (29 added, 2 deleted, 1 changed)
OCL=27197
CL=27469
-rw-r--r-- | doc/go_spec.html | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index 1eb6c7a58..2e5aa626c 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -26,8 +26,6 @@ Todo's: [ ] cleanup: 6g allows: interface { f F } where F is a function type. fine, but then we should also allow: func f F {}, where F is a function type. [ ] decide if and what to write about evaluation order of tuple assignments -[ ] decide if and what to write about evaluation order of composite literal - elements (single expressions, (key:value) pairs) Wish list: [ ] enum facility (enum symbols that are not mixable with ints) or some other @@ -126,6 +124,8 @@ Closed: a for loop that is following, and can break L be used inside it? [x] there is some funniness regarding ';' and empty statements and label decls [x] cleanup convert() vs T() vs x.(T) - convert() should go away? +[x] decide if and what to write about evaluation order of composite literal + elements (single expressions, (key:value) pairs) --> @@ -162,7 +162,7 @@ Expression = Alternative { "|" Alternative } . Alternative = Term { Term } . Term = production_name | token [ "..." token ] | Group | Option | Repetition . Group = "(" Expression ")" . -Option = "[" Expression ")" . +Option = "[" Expression "]" . Repetition = "{" Expression "}" . </pre> @@ -2983,6 +2983,33 @@ Also it may be possible to make typed constants more like variables, at the cost overflow etc. errors being caught. </p> +<h3>Order of evaluation</h3> + +<p> +When evaluating the elements of an assignment or expression, +all function calls, method calls and +communication operations are evaluated in lexical left-to-right +order. Otherwise, the order of evaluation is unspecified. +</p> + +<p> +For example, while evaluating the arguments for this call +to function <code>f</code>, +</p> +<pre> +f(g(), h() + x[i()], <-c) +</pre> +<p> +the call to <code>g()</code> happens before the call to <code>h()</code>, +which happens before the call to <code>i()</code>, all of +of which happen before receiving the value from the channel +<code>c</code>. +However, the order of those events compared to the evaluation of +<code>f</code>, the evaluation of <code>x</code>, and the indexing +of <code>x</code> by the return value of +<code>i()</code> is not specified. +</p> + <hr/> <h2>Statements</h2> |