<!-- title The Go Programming Language Specification -->
-<!-- subtitle Version of July 14, 2010 -->
+<!-- subtitle Version of July 29, 2010 -->
<!--
TODO
<pre class="ebnf">
CompositeLit = LiteralType "{" [ ElementList [ "," ] ] "}" .
LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
- SliceType | MapType | TypeName | "(" LiteralType ")" .
+ SliceType | MapType | TypeName .
ElementList = Element { "," Element } .
Element = [ Key ":" ] Value .
Key = FieldName | ElementIndex .
<p>
A parsing ambiguity arises when a composite literal using the
-TypeName form of the LiteralType appears in the condition of an
+TypeName form of the LiteralType appears between the
+<a href="#Keywords">keyword</a> and the opening brace of the block of an
"if", "for", or "switch" statement, because the braces surrounding
the expressions in the literal are confused with those introducing
-a block of statements. To resolve the ambiguity in this rare case,
+the block of statements. To resolve the ambiguity in this rare case,
the composite literal must appear within
parentheses.
</p>
func main() {
f(map[string]string{"a":"b","c":"d"});
f([...]int{1,2,3});
- f(([...]int){1,2,3});
- f((map[string]string){"a":"b","c":"d"});
- f((map[string]func()){"a":g,"c":g});
+ f(map[string]func(){"a":g,"c":g});
f(make(chan(<-chan int)));
f(make(chan<-(chan int)));
}