1
0
mirror of https://github.com/golang/go synced 2024-10-02 06:18:32 -06:00
go/doc
griesemer b40831b115 spec: explicitly define notion of "representability" (clarification)
Throughout the spec we use the notion of a constant x being
representable by a value of type T. While intuitively clear,
at least for floating-point and complex constants types, the
concept was not well-defined. In the section on Conversions
there was an extra rule for floating-point types only and it
missed the case of floating-point values overflowing to an
infinity after rounding.

Since the concept is important to Go, and a compiler most
certainly will have a function to test "representability",
it seems warranted to define the term explicitly in the spec.

This change introduces a new entry "Representability" under
the section on "Properties of types and values", and defines
the term explicitly, together with examples.

The phrase used is "representable by" rather than "representable as"
because the former use is prevalent in the spec.

Additionally, it clarifies that a floating-point constant
that overflows to an infinity after rounding is never
representable by a value of a floating-point type, even though
infinities are valid values of IEEE floating point types.
This is required because there are not infinite value constants
in the language (like there is also no -0.0) and representability
also matters for constant conversions. This is not a language
change, and type-checkers have been following this rule before.

The change also introduces links throughout the spec to the new
section as appropriate and removes duplicate text and examples
elsewhere (Constants and Conversions sections), leading to
simplifications in the relevant paragraphs.

Fixes #15389.

Change-Id: I8be0e071552df0f18998ef4c5ef521f64ffe8c44
Reviewed-on: https://go-review.googlesource.com/57530
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-08-25 19:54:57 +00:00
..
articles *.bash: always use the same string equality operator 2017-03-14 21:46:31 +00:00
codewalk all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
devel doc: document go1.9 2017-08-24 19:54:25 +00:00
editors doc: add Atom to editor guide 2017-07-25 17:20:27 +00:00
gopher website: recreate 16px and 32px favicon 2016-08-25 15:43:32 +00:00
play doc/play: update URL for concurrent pi 2016-01-06 20:23:21 +00:00
progs all: spell "marshal" and "unmarshal" consistently 2016-11-12 00:13:35 +00:00
asm.html doc: add mips, mips64 information to asm.html 2016-12-20 20:58:12 +00:00
cmd.html doc: website: changed link for cover 2017-06-18 16:19:31 +00:00
code.html doc: Proper default value for the $GOPATH. 2017-06-28 05:47:47 +00:00
conduct.html doc: update Code of Conduct wording and scope 2017-02-15 21:42:39 +00:00
contrib.html doc: add go1.9 to golang.org/project 2017-08-24 19:55:25 +00:00
contribute.html doc/contribute: improve wording of Gerrit description 2017-08-09 15:29:05 +00:00
debugging_with_gdb.html doc/gdb: mention GOTRACEBACK=crash 2017-01-13 18:05:46 +00:00
docs.html doc: add an editor guide 2017-07-19 21:38:16 +00:00
editors.html doc: use better wording to explain type-aware completion 2017-08-04 20:18:16 +00:00
effective_go.html doc: escape some HTML in Effective Go code examples 2017-04-20 16:29:19 +00:00
gccgo_contribute.html doc: fix stale gofrontend/gccgo contribution link 2016-09-01 18:38:38 +00:00
gccgo_install.html doc: update gccgo docs 2017-01-24 21:21:59 +00:00
go1.1.html all: fix misprints in comments 2015-06-11 14:18:57 +00:00
go1.2.html doc: drop scheme from links that are known to support HTTPS 2014-07-25 10:28:39 +10:00
go1.3.html [release-branch.go1.4] doc: scrub references to code.google.com 2014-12-12 14:00:48 +11:00
go1.4.html doc/go1.4.html: fix typo 2015-03-24 18:17:49 +00:00
go1.5.html doc: mention that go install removes binaries built by go build 2015-09-08 18:46:07 +00:00
go1.6.html doc: GCC 6 will have the Go 1.6.1 user libraries 2016-04-14 20:00:33 +00:00
go1.7.html doc: fix broken links in 1.7 release docs 2016-11-07 18:51:29 +00:00
go1.8.html doc: fix broken link in go1.8.html 2017-02-22 23:51:12 +00:00
go1.9.html doc: document go1.9 2017-08-24 19:54:25 +00:00
go1.html doc: link directly to https://golang.org/dl/ 2014-09-12 09:15:58 +10:00
go1compat.html doc: add a clause about embedded methods to go1compat 2015-07-22 01:25:32 +00:00
go_faq.html doc: add qualified mention of dep to FAQ 2017-06-20 16:07:41 +00:00
go_mem.html doc/go_mem.html: correct the channel example 2015-03-16 21:43:31 +00:00
go_spec.html spec: explicitly define notion of "representability" (clarification) 2017-08-25 19:54:57 +00:00
go-logo-black.png doc: pngcrush and remove old, unused images 2012-03-08 14:18:28 +11:00
go-logo-blue.png doc: pngcrush and remove old, unused images 2012-03-08 14:18:28 +11:00
go-logo-white.png doc: pngcrush and remove old, unused images 2012-03-08 14:18:28 +11:00
help.html doc: add Go Time podcast to the help page 2017-04-21 00:42:07 +00:00
ie.css
install-source.html doc: document go1.9 2017-08-24 19:54:25 +00:00
install.html doc: update binary requirements 2017-06-29 22:14:58 +00:00
root.html doc: hide blog content for golang.google.cn 2017-08-03 17:32:52 +00:00
security.html doc: dissuade people from using PGP for security reports 2017-04-17 18:33:08 +00:00
share.png godoc: change link styles, add 'pop out' button 2012-03-13 11:00:11 +11:00
tos.html doc: drop scheme from links that are known to support HTTPS 2014-07-25 10:28:39 +10:00