diff options
| author | Robert Griesemer <gri@golang.org> | 2016-11-04 12:38:53 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2016-11-04 19:57:23 +0000 |
| commit | 87f4e36ce7d7dffbf1f2a869f3014321f6cfff3c (patch) | |
| tree | 0db7ab83bb13fc088b19be793a02bff3a4a35682 | |
| parent | 585a0b03b243e1847b3028bc0f2e77bb3688adba (diff) | |
| download | go-87f4e36ce7d7dffbf1f2a869f3014321f6cfff3c.tar.xz | |
Revert "spec: add new language for alias declarations"
This reverts commit aff37662d1f70f2bf9e47b4f962e85521e7c18d1.
Reason: Decision to back out current alias implementation.
https://github.com/golang/go/issues/16339#issuecomment-258527920
Fixes #16339.
Fixes #17746.
Fixes #17784.
Change-Id: I5737b830d7f6fb79cf36f26403b4ad8533ba1dfe
Reviewed-on: https://go-review.googlesource.com/32813
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
| -rw-r--r-- | doc/go_spec.html | 75 |
1 files changed, 6 insertions, 69 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index 0819b758e6..934bf5db85 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 28, 2016", + "Subtitle": "Version of November 4, 2016", "Path": "/ref/spec" }--> @@ -1726,12 +1726,8 @@ the left is bound to the value of the <i>n</i>th expression on the right. </p> -<p> -For constant <i>aliases</i>, see the section on <a href="#Alias_declarations">alias declarations</a>. -</p> - <pre class="ebnf"> -ConstDecl = "const" ( ConstSpec | AliasSpec | "(" { ( ConstSpec | AliasSpec ) ";" } ")" ) . +ConstDecl = "const" ( ConstSpec | "(" { ConstSpec ";" } ")" ) . ConstSpec = IdentifierList [ [ Type ] "=" ExpressionList ] . IdentifierList = identifier { "," identifier } . @@ -1850,12 +1846,8 @@ and operations defined for the existing type are also defined for the new type. The new type is <a href="#Type_identity">different</a> from the existing type. </p> -<p> -For type <i>aliases</i>, see the section on <a href="#Alias_declarations">alias declarations</a>. -</p> - <pre class="ebnf"> -TypeDecl = "type" ( TypeSpec | AliasSpec | "(" { ( TypeSpec | AliasSpec ) ";" } ")" ) . +TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) . TypeSpec = identifier Type . </pre> @@ -1936,12 +1928,8 @@ A variable declaration creates one or more variables, binds corresponding identifiers to them, and gives each a type and an initial value. </p> -<p> -For variable <i>aliases</i>, see the section on <a href="#Alias_declarations">alias declarations</a>. -</p> - <pre class="ebnf"> -VarDecl = "var" ( VarSpec | AliasSpec | "(" { ( VarSpec | AliasSpec ) ";" } ")" ) . +VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) . VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) . </pre> @@ -1988,7 +1976,6 @@ inside a <a href="#Function_declarations">function body</a> if the variable is never used. </p> - <h3 id="Short_variable_declarations">Short variable declarations</h3> <p> @@ -2019,7 +2006,7 @@ _, y, _ := coord(p) // coord() returns three values; only interested in y coord <p> Unlike regular variable declarations, a short variable declaration may <i>redeclare</i> variables provided they were originally declared earlier in the same block -(or the parameter lists if the block is the function body) with the same type, +(or the parameter lists if the block is the function body) with the same type, and at least one of the non-<a href="#Blank_identifier">blank</a> variables is new. As a consequence, redeclaration can only appear in a multi-variable short declaration. Redeclaration does not introduce a new variable; it just assigns a new value to the original. @@ -2047,12 +2034,8 @@ A function declaration binds an identifier, the <i>function name</i>, to a function. </p> -<p> -For function <i>aliases</i>, see the section on <a href="#Alias_declarations">alias declarations</a>. -</p> - <pre class="ebnf"> -FunctionDecl = "func" ( FunctionName ( Function | Signature ) ) | AliasSpec . +FunctionDecl = "func" FunctionName ( Function | Signature ) . FunctionName = identifier . Function = Signature FunctionBody . FunctionBody = Block . @@ -2165,52 +2148,6 @@ However, a function declared this way is not a method. </p> -<h3 id="Alias_declarations">Alias declarations</h3> - -<p> -An alias declaration binds an identifier, the <i>alias</i>, to a -<a href="#Constant_declarations">constant</a>, -<a href="#Type_declarations">type</a>, -<a href="#Variable_declarations">variable</a>, or -<a href="#Function_declarations">function</a> -denoted by a <a href="#Qualified_identifiers">qualified identifier</a> and -declared in a different package. -</p> - -<pre class="ebnf"> -AliasSpec = identifier "=>" QualifiedIdent . -</pre> - -<p> -The effect of referring to a constant, type, variable, or function by an alias -is indistinguishable from referring to it by its original name. -For example, the type denoted by a type alias and the aliased type are -<a href="#Type_identity">identical</a>. -</p> - -<p> -An alias declaration may appear only as a form of constant, type, variable, -or function declaration at the package level, and the aliased entity must be -a constant, type, variable, or function respectively. Alias declarations inside -functions are not permitted. -</p> - -<pre> -const ( - G = 6.67408e-11 // regular and alias declarations may be grouped - Pi => math.Pi // same effect as: Pi = math.Pi -) - -type Struct => types.Struct // re-export of types.Struct - -func sin => math.Sin // non-exported shortcut for frequently used function -</pre> - -<p> -An alias declaration may not refer to package <a href="#Package_unsafe">unsafe</a>. -</p> - - <h2 id="Expressions">Expressions</h2> <p> |
