Commit a27f1f74 authored by Robert Griesemer's avatar Robert Griesemer

use the notion of "untyped constant" instead of "ideal constant"

R=iant
DELTA=13  (1 added, 0 deleted, 12 changed)
OCL=35241
CL=35246
parent 53440da8
...@@ -257,21 +257,22 @@ You cannot write <code>c = *p++</code>. <code>*p++</code> is parsed as ...@@ -257,21 +257,22 @@ You cannot write <code>c = *p++</code>. <code>*p++</code> is parsed as
<h2 id="Constants">Constants </h2> <h2 id="Constants">Constants </h2>
<p> <p>
In Go integer and floating-point constants have so-called ideal types. In Go constants may be <i>untyped</i>. This applies even to constants
This applies even to constants named with a <code>const</code> declaration, named with a <code>const</code> declaration if no
if no type is given in the declaration and the initializer expression uses only
type is given in the declaration. An ideal type becomes concrete when untyped constants.
it is actually used. This permits constants to be used relatively An untyped constant becomes typed when it is used within a context that
requires a typed value. This permits constants to be used relatively
freely without requiring general implicit type conversion. freely without requiring general implicit type conversion.
<pre> <pre>
var a uint; f(a + 1) // Ideal type of "1" becomes "uint". var a uint; f(a + 1) // untyped numeric constant "1" becomes typed as uint
</pre> </pre>
<p> <p>
The language does not impose any limits on the size of an abstract The language does not impose any limits on the size of an untyped
integer constant or constant expression. A limit is only applied when numeric constant or constant expression. A limit is only applied when
a constant expression is used where a type is required. a constant is used where a type is required.
<pre> <pre>
const huge = 1 &lt;&lt; 100; f(huge &gt;&gt; 98) const huge = 1 &lt;&lt; 100; f(huge &gt;&gt; 98)
......
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