Commit 0e1d941e authored by Robert Griesemer's avatar Robert Griesemer

go spec: clarify address operators.

Fixes #1445.

R=r, rsc, iant, ken2
CC=golang-dev
https://golang.org/cl/4109041
parent 4e221896
<!-- title The Go Programming Language Specification --> <!-- title The Go Programming Language Specification -->
<!-- subtitle Version of January 18, 2011 --> <!-- subtitle Version of January 26, 2011 -->
<!-- <!--
TODO TODO
...@@ -2053,7 +2053,7 @@ For array and slice literals the following rules apply: ...@@ -2053,7 +2053,7 @@ For array and slice literals the following rules apply:
<p> <p>
Taking the address of a composite literal (§<a href="#Address_operators">Address operators</a>) Taking the address of a composite literal (§<a href="#Address_operators">Address operators</a>)
generates a unique pointer to an instance of the literal's value. generates a pointer to a unique instance of the literal's value.
</p> </p>
<pre> <pre>
var pointer *Point3D = &amp;Point3D{y: 1000} var pointer *Point3D = &amp;Point3D{y: 1000}
...@@ -2983,15 +2983,19 @@ The right operand is evaluated conditionally. ...@@ -2983,15 +2983,19 @@ The right operand is evaluated conditionally.
<h3 id="Address_operators">Address operators</h3> <h3 id="Address_operators">Address operators</h3>
<p> <p>
The address-of operator <code>&amp;</code> generates the address of its operand, For an operand <code>x</code> of type <code>T</code>, the address operation
which must be <i>addressable</i>, <code>&amp;x</code> generates a pointer of type <code>*T</code> to <code>x</code>.
The operand must be <i>addressable</i>,
that is, either a variable, pointer indirection, or slice indexing that is, either a variable, pointer indirection, or slice indexing
operation; operation; or a field selector of an addressable struct operand;
or a field selector of an addressable struct operand;
or an array indexing operation of an addressable array. or an array indexing operation of an addressable array.
Given an operand of pointer type, the pointer indirection As an exception to the addressability requirement, <code>x</code> may also be a
operator <code>*</code> retrieves the value pointed <a href="#Composite_literals">composite literal</a>.
to by the operand. </p>
<p>
For an operand <code>x</code> of pointer type <code>*T</code>, the pointer
indirection <code>*x</code> denotes the value of type <code>T</code> pointed
to by <code>x</code>.
</p> </p>
<pre> <pre>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment