mirror of
https://github.com/golang/go
synced 2024-11-25 06:57:58 -07:00
go_spec: fixed a couple omissions/type errors
- use math.Sqrt instead of Math.sqrt - use float64 for Point fields to match math.Sqrt - distinguish between Point and Point3D for clarity - add alignment sizes for complex types R=r, rsc, iant, ken2 CC=golang-dev https://golang.org/cl/3420041
This commit is contained in:
parent
b88b38ac12
commit
777a96a5b0
@ -1,5 +1,5 @@
|
|||||||
<!-- title The Go Programming Language Specification -->
|
<!-- title The Go Programming Language Specification -->
|
||||||
<!-- subtitle Version of Nov 4, 2010 -->
|
<!-- subtitle Version of December 2, 2010 -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
TODO
|
TODO
|
||||||
@ -1661,7 +1661,7 @@ TypeSpec = identifier Type .
|
|||||||
type IntArray [16]int
|
type IntArray [16]int
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Point struct { x, y float }
|
Point struct { x, y float64 }
|
||||||
Polar Point
|
Polar Point
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1878,13 +1878,13 @@ Given type <code>Point</code>, the declarations
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
func (p *Point) Length() float {
|
func (p *Point) Length() float64 {
|
||||||
return Math.sqrt(p.x * p.x + p.y * p.y)
|
return math.Sqrt(p.x * p.x + p.y * p.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Point) Scale(factor float) {
|
func (p *Point) Scale(factor float64) {
|
||||||
p.x = p.x * factor
|
p.x *= factor
|
||||||
p.y = p.y * factor
|
p.y *= factor
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@ -1906,7 +1906,7 @@ argument. For instance, the method <code>Scale</code> has type
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
func(p *Point, factor float)
|
func(p *Point, factor float64)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2025,8 +2025,8 @@ For struct literals the following rules apply:
|
|||||||
Given the declarations
|
Given the declarations
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
type Point struct { x, y, z float }
|
type Point3D struct { x, y, z float64 }
|
||||||
type Line struct { p, q Point }
|
type Line struct { p, q Point3D }
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2034,8 +2034,8 @@ one may write
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
origin := Point{} // zero value for Point
|
origin := Point3D{} // zero value for Point3D
|
||||||
line := Line{origin, Point{y: -4, z: 12.3}} // zero value for line.q.x
|
line := Line{origin, Point3D{y: -4, z: 12.3}} // zero value for line.q.x
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2058,7 +2058,7 @@ Taking the address of a composite literal (§<a href="#Address_operators">Addres
|
|||||||
generates a unique pointer to an instance of the literal's value.
|
generates a unique pointer to an instance of the literal's value.
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
var pointer *Point = &Point{y: 1000}
|
var pointer *Point3D = &Point3D{y: 1000}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2210,7 +2210,7 @@ Point{1, 2}
|
|||||||
m["foo"]
|
m["foo"]
|
||||||
s[i : j + 1]
|
s[i : j + 1]
|
||||||
obj.color
|
obj.color
|
||||||
Math.sin
|
math.Sin
|
||||||
f.p[i].x()
|
f.p[i].x()
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@ -5204,7 +5204,8 @@ type size in bytes
|
|||||||
byte, uint8, int8 1
|
byte, uint8, int8 1
|
||||||
uint16, int16 2
|
uint16, int16 2
|
||||||
uint32, int32, float32 4
|
uint32, int32, float32 4
|
||||||
uint64, int64, float64 8
|
uint64, int64, float64, complex64 8
|
||||||
|
complex128 16
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user