mirror of
https://github.com/golang/go
synced 2024-11-25 01:08:02 -07:00
spec: minor tweaks
- more idiomatic examples of pointer types - show use of _ in examples of function types - remove "legal:" qualification in examples for consistency R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5711054
This commit is contained in:
parent
b5d4cffd15
commit
953f2dec89
@ -1,6 +1,6 @@
|
||||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of February 29, 2012"
|
||||
"Subtitle": "Version of March 1, 2012"
|
||||
}-->
|
||||
|
||||
<!--
|
||||
@ -1007,8 +1007,8 @@ BaseType = Type .
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
*int
|
||||
*map[string]*chan int
|
||||
*Point
|
||||
*[4]int
|
||||
</pre>
|
||||
|
||||
<h3 id="Function_types">Function types</h3>
|
||||
@ -1046,11 +1046,10 @@ may be invoked with zero or more arguments for that parameter.
|
||||
|
||||
<pre>
|
||||
func()
|
||||
func(x int)
|
||||
func() int
|
||||
func(prefix string, values ...int)
|
||||
func(a, b int, z float32) bool
|
||||
func(x int) int
|
||||
func(a, _ int, z float32) bool
|
||||
func(a, b int, z float32) (bool)
|
||||
func(prefix string, values ...int)
|
||||
func(a, b int, z float64, opt ...interface{}) (success bool)
|
||||
func(int, int, float64) (float64, *[]int)
|
||||
func(n int) func(p *T)
|
||||
@ -2788,13 +2787,13 @@ var s uint = 33
|
||||
var i = 1<<s // 1 has type int
|
||||
var j int32 = 1<<s // 1 has type int32; j == 0
|
||||
var k = uint64(1<<s) // 1 has type uint64; k == 1<<33
|
||||
var m int = 1.0<<s // legal: 1.0 has type int
|
||||
var n = 1.0<<s != 0 // legal: 1.0 has type int; n == false if ints are 32bits in size
|
||||
var o = 1<<s == 2<<s // legal: 1 and 2 have type int; o == true if ints are 32bits in size
|
||||
var m int = 1.0<<s // 1.0 has type int
|
||||
var n = 1.0<<s != 0 // 1.0 has type int; n == false if ints are 32bits in size
|
||||
var o = 1<<s == 2<<s // 1 and 2 have type int; o == true if ints are 32bits in size
|
||||
var p = 1<<s == 1<<33 // illegal if ints are 32bits in size: 1 has type int, but 1<<33 overflows int
|
||||
var u = 1.0<<s // illegal: 1.0 has type float64, cannot shift
|
||||
var v float32 = 1<<s // illegal: 1 has type float32, cannot shift
|
||||
var w int64 = 1.0<<33 // legal: 1.0<<33 is a constant shift expression
|
||||
var w int64 = 1.0<<33 // 1.0<<33 is a constant shift expression
|
||||
</pre>
|
||||
|
||||
<h3 id="Operator_precedence">Operator precedence</h3>
|
||||
|
Loading…
Reference in New Issue
Block a user