Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
c956e909
Commit
c956e909
authored
Apr 15, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a section about order of evaluation
DELTA=32 (29 added, 2 deleted, 1 changed) OCL=27197 CL=27469
parent
935953a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
go_spec.html
doc/go_spec.html
+30
-3
No files found.
doc/go_spec.html
View file @
c956e909
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment