From f5c07634322229391ef25513a8c3efa77e423649 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Thu, 1 May 2008 23:51:33 -0700 Subject: [PATCH] Explain about pointer types for mutually recursive structures. SVN=117463 --- doc/go_lang.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/go_lang.txt b/doc/go_lang.txt index 3479d298740..7fc7c27ffb6 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.