]> Cypherpunks repositories - gostls13.git/commitdiff
Explain about pointer types for mutually recursive structures.
authorRob Pike <r@golang.org>
Fri, 2 May 2008 06:51:33 +0000 (23:51 -0700)
committerRob Pike <r@golang.org>
Fri, 2 May 2008 06:51:33 +0000 (23:51 -0700)
SVN=117463

doc/go_lang.txt

index 3479d2987401fdfebaf96339ab5b2fb85f6e7f68..7fc7c27ffb6cae7c78a02b66ced02b06dbce0f85 100644 (file)
@@ -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.