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
38c083c1
Commit
38c083c1
authored
May 01, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require names for return values for functions with complex return types.
SVN=117346
parent
50cea703
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
19 deletions
+15
-19
go_lang.txt
doc/go_lang.txt
+9
-13
sys.go
src/lib/math/sys.go
+3
-3
sys.go
src/lib/sys.go
+3
-3
No files found.
doc/go_lang.txt
View file @
38c083c1
...
...
@@ -1461,12 +1461,18 @@ explicitly list the return value or values in the return statement:
return 2;
}
func complex_f1() (float, float) {
A function may return multiple values.
The syntax of the return clause in that case is the same as
that of a parameter list; in particular, names must be provided for
the elements of the return value.
func complex_f1() (re float, im float) {
return -7.0, -4.0;
}
The second is to provide names for the return values and assign them
explicitly in the function; the return statement will then provide no
The second method to return values
is to use those names within the function as variables
to be assigned explicitly; the return statement will then provide no
values:
func complex_f2() (re float, im float) {
...
...
@@ -1475,14 +1481,6 @@ values:
return;
}
It is legal to name the return values in the declaration even if the
first form of return statement is used:
func complex_f2() (re float, im float) {
return 7.0, 4.0;
}
If statements
----
...
...
@@ -1817,5 +1815,3 @@ TODO
- TODO: type switch?
- TODO: words about slices
- TODO: I (gri) would like to say that sizeof(int) == sizeof(pointer), always.
- TODO: when are two types equal? consider
func iterate(f *func(int, interface{}), arg interface{})
src/lib/math/sys.go
View file @
38c083c1
...
...
@@ -4,9 +4,9 @@
package
sys
func
modf
(
a
double
)
(
double
,
double
);
func
frexp
(
a
double
)
(
int
,
double
);
func
ldexp
(
double
,
int
)
double
;
func
modf
(
a
double
)
(
x
double
,
y
double
);
func
frexp
(
a
double
)
(
e
int
,
m
double
);
func
ldexp
(
f
double
,
e
int
)
double
;
func
Inf
(
n
int
)
double
;
func
NaN
()
double
;
...
...
src/lib/sys.go
View file @
38c083c1
...
...
@@ -4,9 +4,9 @@
package
sys
func
modf
(
a
double
)
(
double
,
double
);
func
frexp
(
a
double
)
(
int
,
double
);
func
ldexp
(
double
,
int
)
double
;
func
modf
(
a
double
)
(
x
double
,
y
double
);
func
frexp
(
a
double
)
(
e
int
,
m
double
);
func
ldexp
(
f
double
,
e
int
)
double
;
func
Inf
(
n
int
)
double
;
func
NaN
()
double
;
...
...
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