From: Rob Pike Date: Fri, 2 May 2008 06:51:33 +0000 (-0700) Subject: Explain about pointer types for mutually recursive structures. X-Git-Tag: weekly.2009-11-06~3784 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f5c07634322229391ef25513a8c3efa77e423649;p=gostls13.git Explain about pointer types for mutually recursive structures. SVN=117463 --- diff --git a/doc/go_lang.txt b/doc/go_lang.txt index 3479d29874..7fc7c27ffb 100644 --- a/doc/go_lang.txt +++ b/doc/go_lang.txt @@ -683,6 +683,15 @@ We do not allow pointer arithmetic of any kind. *int *map[string] *chan +It is legal to write a pointer type (only) such as *T or **T even if T +is not yet defined as a type name. This allows the construction of +mutually recursive data types such as structs: + + type S1 struct { s2 *S2 } // S2 is not yet declared + type S2 struct { s1 *S1 } + +By the end of the package source, such types must be fully declared. + There are no pointer literals.