aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2014-10-27 16:31:15 -0700
committerRobert Griesemer <gri@golang.org>2014-10-27 16:31:15 -0700
commitccc713c7caa8900facc99bffaad4ee4a22013b01 (patch)
tree1e0a64649f9554895c6097a42fafead1ba9619f9
parente71c9cbe260941bfb322c69e4a4f10b4323a228e (diff)
downloadgo-ccc713c7caa8900facc99bffaad4ee4a22013b01.tar.gz
go-ccc713c7caa8900facc99bffaad4ee4a22013b01.zip
spec: permit parentheses around builtin function names
Not a language change. This is simply documenting the status quo which permits builtin function names to be parenthesized in calls; e.g., both len(s) and (((len)))(s) are accepted by all compilers and go/types. Changed the grammar by merging the details of BuiltinCall with ordinary Calls. Also renamed the Call production to Arguments which more clearly identifies that part of the grammar and also matches better with its counterpart on the declaration side (Parameters). The fact that the first argument can be a type (for builtins) or cannot be a type (for regular function calls) is expressed in the prose, no need to make the grammar more complicated. Fixes #9001. LGTM=iant, r, rsc R=r, rsc, iant, ken, dave CC=golang-codereviews https://golang.org/cl/160570043
-rw-r--r--doc/go_spec.html15
1 files changed, 4 insertions, 11 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html
index ad645c1ffc..050c06465d 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
- "Subtitle": "Version of October 23, 2014",
+ "Subtitle": "Version of October 27, 2014",
"Path": "/ref/spec"
}-->
@@ -2449,12 +2449,11 @@ Primary expressions are the operands for unary and binary expressions.
PrimaryExpr =
Operand |
Conversion |
- BuiltinCall |
PrimaryExpr Selector |
PrimaryExpr Index |
PrimaryExpr Slice |
PrimaryExpr TypeAssertion |
- PrimaryExpr Call .
+ PrimaryExpr Arguments .
Selector = "." identifier .
Index = "[" Expression "]" .
@@ -2462,8 +2461,7 @@ Slice = "[" ( [ Expression ] ":" [ Expression ] ) |
( [ Expression ] ":" Expression ":" Expression )
"]" .
TypeAssertion = "." "(" Type ")" .
-Call = "(" [ ArgumentList [ "," ] ] ")" .
-ArgumentList = ExpressionList [ "..." ] .
+Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
</pre>
@@ -3166,7 +3164,7 @@ the method.
<pre>
math.Atan2(x, y) // function call
var pt *Point
-pt.Scale(3.5) // method call with receiver pt
+pt.Scale(3.5) // method call with receiver pt
</pre>
<p>
@@ -5371,11 +5369,6 @@ so they can only appear in <a href="#Calls">call expressions</a>;
they cannot be used as function values.
</p>
-<pre class="ebnf">
-BuiltinCall = identifier "(" [ BuiltinArgs [ "," ] ] ")" .
-BuiltinArgs = Type [ "," ArgumentList ] | ArgumentList .
-</pre>
-
<h3 id="Close">Close</h3>
<p>