diff --git a/doc/go_spec.html b/doc/go_spec.html index 008a8f88c0..094ec77051 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -9,6 +9,10 @@ Open issues: Todo's: +[ ] need language about function/method calls and parameter passing rules +[ ] update language with respect to forward declarations +[ ] clarify what a field name is in struct declarations + (struct{T} vs struct {T T} vs struct {t T}) [ ] need explicit language about the result type of operations [ ] may want to have some examples for the types of shift operations [ ] document illegality of package-external tuple assignments to structs @@ -3624,21 +3628,26 @@ and optionally provides a result value or values to the caller. ReturnStmt = "return" [ ExpressionList ] . +
+In a function without a result type, a "return" statement must not +specify any result values. +
-func procedure() {
+func no_result() {
return
}
-There are two ways to return values from a function with a result -type. The first is to explicitly list the return value or values -in the "return" statement. -Normally, the expressions -must be single-valued and assignment-compatible to the elements of -the result type of the function. +There are three ways to return values from a function with a result +type:
+
func simple_f() int {
return 2
@@ -3648,29 +3657,25 @@ func complex_f1() (re float, im float) {
return -7.0, -4.0
}
-
--However, if the expression list in the "return" statement is a single call -to a multi-valued function, the values returned from the called function -will be returned from this one. The result types of the current function -and the called function must match. -
- +
func complex_f2() (re float, im float) {
return complex_f1()
}
-
--The second way to return values is to use the elements of the -result list of the function as variables. When the function begins -execution, these variables are initialized to the zero values for -their type (§The zero value). The function can assign them as -necessary; if the "return" provides no values, those of the variables -will be returned to the caller. -
- +
func complex_f3() (re float, im float) {
re = 7.0;
@@ -3678,9 +3683,15 @@ func complex_f3() (re float, im float) {
return;
}
+
-TODO: Define when return is required.
+
+TODO: Define when return is required.
+TODO: Language about result parameters needs to go into a section on
+ function/method invocation
+