Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
266b9d49
Commit
266b9d49
authored
Mar 03, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added language for range statement
SVN=111200
parent
328df636
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
11 deletions
+33
-11
doc/go_spec
doc/go_spec
+33
-11
No files found.
doc/go_spec
View file @
266b9d49
The
Go
Annotated
Specification
This
document
supersedes
all
previous
Go
spec
attempts
.
The
intent
is
to
make
this
a
reference
for
syntax
and
semantics
.
It
is
annotated
This
document
supersedes
all
previous
Go
spec
attempts
.
The
intent
is
to
make
this
a
reference
for
syntax
and
semantics
.
It
is
annotated
with
additional
information
not
strictly
belonging
into
a
language
spec
.
Open
questions
-
how
to
do
map
iteration
?
should
be
symmetric
to
array
iteration
for
k
in
m
{
...
}
for
k
:
v
in
m
{
...
}
for
:
v
in
m
{
...
}
-
how
to
delete
from
a
map
-
how
to
test
for
map
membership
(
we
may
want
an
'atomic install'
?
m
[
i
]
?=
x
;
)
...
...
@@ -710,6 +705,7 @@ PointerType = '*' Type.
-
We
do
not
allow
pointer
arithmetic
of
any
kind
.
Interface
types
-
TBD
:
This
needs
to
be
much
more
precise
.
For
now
we
understand
what
it
means
.
...
...
@@ -1013,9 +1009,10 @@ func (p *T) foo (a, b int, z float) bool;
Statements
Statement = EmptyStat | Assignment | CompoundStat | Declaration |
ExpressionStat | IncDecStat | IfStat | WhileStat | ForStat |
ReturnStat .
Statement =
EmptyStat | Assignment | CompoundStat | Declaration |
ExpressionStat | IncDecStat | IfStat | WhileStat | ForStat |
RangeStat | ReturnStat .
Empty statements
...
...
@@ -1094,6 +1091,31 @@ ForStat = 'for' ...
Range statements
Range statements denote iteration over the contents of arrays and maps.
RangeStat = '
range
' IdentifierList '
:=
' RangeExpression Block .
RangeExpression = Expression .
A range expression must evaluate to an array, map or string. The identifier list must contain
either one or two identifiers. If the range expression is a map, a single identifier is declared
to range over the keys of the map; two identifiers range over the keys and corresponding
values. For arrays and strings, the behavior is analogous for integer indices (the keys) and array
elements (the values).
a := [ 1, 2, 3];
m := [ "fo" : 2, "foo" : 3, "fooo" : 4 ]
range i := a {
f(a[i]);
}
range k, v := m {
assert(len(k) == v);
}
Return statements
ReturnStat = '
return
' [ ExpressionList ] .
...
...
@@ -1154,7 +1176,7 @@ Precedence Operator
2
&&
3
==
!= < <= > >=
4
+
-
|
^
5
*
/
%
<<
>>
&
5
*
/
%
<<
>>
&
For
integer
values
,
/
and
%
satisfy
the
following
relationship
:
...
...
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