They have been deleted from package unsafe.
Also delete their appearance in exp/types.
Fixes#3338.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5847056
- Define what it means for two identifiers to be unique.
- The current spec is incorrect about exported
identifiers: for instance, it excluded fields
of non-exported types of exported variables
from being exported. It is easier to leave
the detailed specification away and let the
rest of the spec govern access of exported
identifiers.
- The current spec is incorrect about qualified
identifiers: It simply required that an identifier
be exported to be valid in a qualified identifier.
However, qualified identifiers can only access
exported identifiers declared in the package
block of the imported package.
Fixes#1551.
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/5711043
- 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
When we first wrote the method set definition, we had long
discussions about whether method sets applied to all types
or just named types, and we (or at least I) concluded that it
didn't matter: the two were equivalent points of view, because
the only way to introduce a new method was to write a method
function, which requires a named receiver type.
However, the addition of embedded types changed this.
Embedding can introduce a method without writing an explicit
method function, as in:
var x struct {
sync.Mutex
}
var px *struct {
sync.Mutex
}
var _, _ sync.Locker = &x, px
The edits in this CL make clear that both &x and px satisfy
sync.Locker. Today, gccgo already works this way; 6g does not.
R=golang-dev, gri, iant, r
CC=golang-dev
https://golang.org/cl/5702062
Or, depending on your point of view, make the
comparisons satisfy any surrounding boolean type.
Also, fix a few foo_bar -> fooBar in code fragments.
Fixes#2561.
R=golang-dev, r, bradfitz, gri, iant, kevlar
CC=golang-dev
https://golang.org/cl/5671096
Drop reference to "machine type." Specify that integer
overflow must be an error. Drop requirement that exponent
must be 128 bits--that's a lot. Clarify that floating point
expressions may be rounded, including intermediate values.
This is a reworking of https://golang.org/cl/5577068/ .
Fixes#2789.
R=r, rsc, r, gri, ken, ken, iant
CC=golang-dev, remyoudompheng
https://golang.org/cl/5655049
The paragraph describing the ellipses presents the horizontal ellipsis
in two different fonts and at least on my screen they look too different.
Switch to a consistent rendering.
Of small steps are great journeys undertaken.
R=golang-dev, rsc, dsymonds, gri
CC=golang-dev
https://golang.org/cl/5650055
Other wordings are possible but defining this as one
of the ways to proceed means we don't have to add
language about this to the description of select.
Fixes#2825.
R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5643062
Document that indirection through a nil pointer will panic.
Explain function invocation.
This section will need more work, but it's a start.
Fixes#1865.
Fixes#2252.
R=rsc, iant, r
CC=golang-dev
https://golang.org/cl/5532114
This allows HTML pages to specify arbitrary data in a header:
<!--{
"Title": "The page title",
...
}-->
replacing the old style comments:
<!-- title The page title -->
R=gri, rsc, r, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/5532093
- define "0-sized"
- add clarifying sentence to pointer comparison
- removed notion "location" which was used only in pointer comparisons
and which was never defined
Fixes#2620.
R=r, rsc, iant
CC=golang-dev
https://golang.org/cl/5528053
Several places mentioned tokens spanning "multiple lines"
which is not a well-defined term in the spec; newline is.
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/5490046
This change guarantees that whether the line ending convention
when the source is created includes carriage returns is irrelevant
to the value of the string. See issue 680.
The compilers do not yet implement this.
R=golang-dev, adg, r, gri, rsc, iant
CC=golang-dev
https://golang.org/cl/5491043
Also, clarify when interface comparison panics and
that comparison to nil is a special syntax rather than
a general comparison rule.
R=r, gri, r, iant, cw, bradfitz
CC=golang-dev
https://golang.org/cl/5440117
This is a spec correction, not a language change.
The implementations have behaved like this for years
(and there are tests to that effect), and elsewhere in
the spec true and false are defined to be untyped
boolean constants.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5477047
This has always been true, but we lost it from the spec
somewhere along the way, probably when we disallowed
the general 'pointer to anything sliceable' slice case.
R=gri
CC=golang-dev
https://golang.org/cl/5437121
The allowed conversions before and after are:
type Tstring string
type Tbyte []byte
type Trune []rune
string <-> string // ok
string <-> []byte // ok
string <-> []rune // ok
string <-> Tstring // ok
string <-> Tbyte // was illegal, now ok
string <-> Trune // was illegal, now ok
Tstring <-> string // ok
Tstring <-> []byte // ok
Tstring <-> []rune // ok
Tstring <-> Tstring // ok
Tstring <-> Tbyte // was illegal, now ok
Tstring <-> Trune // was illegal, now ok
Update spec, compiler, tests. Use in a few packages.
We agreed on this a few months ago but never implemented it.
Fixes#1707.
R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5421057
An experiment: allow structs to be copied even if they
contain unexported fields. This gives packages the
ability to return opaque values in their APIs, like reflect
does for reflect.Value but without the kludgy hacks reflect
resorts to.
In general, we trust programmers not to do silly things
like *x = *y on a package's struct pointers, just as we trust
programmers not to do unicode.Letter = unicode.Digit,
but packages that want a harder guarantee can introduce
an extra level of indirection, like in the changes to os.File
in this CL or by using an interface type.
All in one CL so that it can be rolled back more easily if
we decide this is a bad idea.
Originally discussed in March 2011.
https://groups.google.com/group/golang-dev/t/3f5d30938c7c45ef
R=golang-dev, adg, dvyukov, r, bradfitz, jan.mercl, gri
CC=golang-dev
https://golang.org/cl/5372095
This is true of the existing implementations, and I think
it is an important property to guarantee.
R=golang-dev, r, borman, r
CC=golang-dev
https://golang.org/cl/5321058
This is not a language change.
Added paragraphs specifying which conversions
yield results that are constants.
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/4515176
This is (indirectly) a language change. Per e-mail discussion
on golang-dev.
Fixes#1943.
R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/4581058
- Added some additional examples.
- 6g appears to implement this semantics already.
Fixes#658.
R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/4538119
Note: This is not a spec change.
The spec was not clear on the result type of
constant shift expressions. Made it more
explicit and added additional examples.
Also: Remove paragraph on send expressions (they
are statements, now).
Fixes#1708.
R=rsc, r, iant, r
CC=golang-dev
https://golang.org/cl/4517074
This CL proposes some subtle language changes
in an attempt to clarify the semantics of range
clauses and simplify uses of maps.
- nil maps behave like empty maps; but attempting
to set a value in a nil map causes a run-time panic
- nil channels are never ready for communication;
sending or reading from a nil channel blocks forever
- if there is only one index iteration variable in a
range clause and len(range expression) would be a constant,
the range expression is not evaluated.
(was discrepancy with len/cap before)
- the notion of what is a constant expression len(x)
for (pointer to) arrays x has been generalized and
simplified (can still be syntactically decided)
(before: more restrictive syntactic rule that was not
consistently implemented)
Fixes#1713.
R=r, rsc, iant, ken2, r2, bradfitz, rog
CC=golang-dev
https://golang.org/cl/4444050
No language change.
- added a few examples with parentheses
- added a corresponding sentence to assignments
(this explicitly permits: (_) = 0, currently allowed by 6g,
gofmt, but marked as an error by gccgo).
R=rsc, r, iant
CC=golang-dev
https://golang.org/cl/4446071
The CL introduces inconsistencies with respect to
the use of parentheses/grouping of receive operations.
««« original CL description
spec: narrow syntax for expression and select statements
This is not a language change, it simply expresses the
accepted cases explicitly in the respective productions.
R=rsc, r, iant
CC=golang-dev
https://golang.org/cl/4428057
»»»
R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4444080
This is not a language change, it simply expresses the
accepted cases explicitly in the respective productions.
R=rsc, r, iant
CC=golang-dev
https://golang.org/cl/4428057
Computer people have an agglutinating streak that I like to resist.
As a time of execution: run time.
As an adjective: run-time.
As a noun: run-time support/code/library.
Signed,
Mr. Pedant.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4252048
- added an example to Type declarations section clarifying the
situation brought up with issue 1324
- slightly re-ordered paragraphs in Types section
- added separate heading for method set section and refer to it
from elsewhere in the spec
- no language changes
R=rsc, r, iant, ken2, r2
CC=golang-dev
https://golang.org/cl/4145043
Removed most of the detailed examples about handing panics
from the go spec since it's now covered by Effective Go.
R=r, rsc, iant, ken2
CC=golang-dev
https://golang.org/cl/4128058
This change makes it legal to pass a struct value as receiver
outside the package declaring the struct even if the respective
struct type has non-exported fields.
This is a backwards-compatible language change motivated by the
fact that it is already possible to circumvent the assignment
restriction when calling methods through interfaces (see issue
1402).
R=r, rsc, iant, ken2
CC=golang-dev
https://golang.org/cl/3926044
Prior to this CL, there were two requirements about the
package name main.
1. The package that sits at the root of the import graph
(the one where program execution begins)
must be named main.
2. No other package in the program can be named main.
This CL only removes requirement #2, which can be done
without changing any other Go documentation.
The new wording and formatting is such that removing
requirement #1 can be done by deleting a single line,
but making that change is explicitly outside the scope
of this CL, because it would require changes to other
documentation at the same time.
R=gri, r, gri1
CC=golang-dev
https://golang.org/cl/4126053
These are syntactical changes to better reflect the communication
operator's new status in the language.
- sending to a channel is now done via a send statement
- there is no binary communication operation anymore which
leads to a reduction of the number of precedence levels
from 6 to 5 (yeah!)
- small semantic change: since a send operation is not part
of the expression syntax anymore, a <- send operator is
binding weaker than any other operator now
- receiving from a channel is done as before via the unary
receive expression
- communication clauses in select statement now can contain
send statements or receive expressions
R=rsc, r, iant, ken2, gri1
CC=golang-dev
https://golang.org/cl/3973051
Close of closed channel panics.
Receive from closed channel never panics,
even if done repeatedly.
Fixes#1349.
Fixes#1419.
R=gri, iant, ken2, r, gri1, r2, iant2, rog, albert.strasheim, niemeyer, ejsherry
CC=golang-dev
https://golang.org/cl/3989042
The default float type is not very useful but for the most basic applications.
For instance, as it is now, using the math package requires conversions for float
variables (the arguments for math functions are usually float64). Typical real
applications tend to specify the floating point precision required.
This proposal removes the predeclared types float and complex. Variable declarations
without type specification but with constant floating point or complex initializer
expressions will assume the type float64 or complex128 respectively.
The predeclared function cmplx is renamed to complex.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/3423041
- 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
Added a "return" to the end of an example which previously threw a compile error if used.
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/3052041
Consistency argument: A valid Go program should
remain valid after stripping leading and trailing
whitespace. This was not true so far if the last
text in the source was a line comment.
R=iant, ken2, r, rsc, r2
CC=golang-dev
https://golang.org/cl/2906041
For elements which are themselves composite literals, the type may
be omitted if it is identical to the element type of the containing
composite literal.
R=r, rsc, iant, ken2
CC=golang-dev
https://golang.org/cl/2661041
Background: The current spec is imprecise with respect to the parsing ambiguity
for composite literals: It says that the ambiguity arises when the TypeName form
of the LiteralType is used. The following code:
if (B) {} ...
is not using the TypeName form (but the parenthesized TypeName form) and thus
could be interpreted as:
if ((B){}) ...
instead of
if B {} ...
Both compilers and gofmt choose the latter interpretation. One could fix the
spec by making the clause regarding the parsing ambiguity more precise ("...using
the _possibly parenthesized_ TypeName form of the LiteralType..."). The alternative
(chosen here) is to simply disallow parenthesized literal types. Except for a single
test case (test/parentype.go) there appears to be no Go code under $GOROOT containing
parenthesized literal types. Furthermore, parentheses are never needed around a
literal type for correct parsing.
R=golang-dev
CC=golang-dev
https://golang.org/cl/1913041
We didn't mention this explicitly during our discussions,
but I think it fits the "identical types are spelled identically"
rule that we used.
R=gri, iant, ken2, r, rsc1
CC=golang-dev
https://golang.org/cl/1698043
Specifically:
- introduced notion of "underlying type"
- removed notion of type compatibility
- consolidated rules about assignment compatibility in
assignment compatibility section
- be consistent with specyfing that nil is the value
for uninitialized variables that can be nil (this
was not specified clearly for pointers, functions, interfaces)
- added/fixed various related links throughout
- clarify language on conversions
R=rsc, r, iant, ken2
CC=golang-dev
https://golang.org/cl/1536041
Specifically:
- Simplified definition of comparison compatibility and folded into
section on comparison operators since it's only used there.
This is a small language change/cleanup. As a consequence:
- An interface value may now be compared against a non-interface value.
- Channels with opposite directions cannot be compared directly anymore
(per discussion with rsc).
R=rsc, r, iant, ken2
CC=golang-dev
https://golang.org/cl/1462041
and adjust conversion rules.
Also:
- clarification of type identity (no language change)
- adjust special rules for channel assignment/comparison to
require identical element types (in correspondence to non-
recursiveness of type compatibility)
R=rsc, iant, ken2, r
CC=golang-dev
https://golang.org/cl/1376042
- also added links to the respective sections
- reformatted section for better (source html) readability
- added missing closing </li>'s in many places
R=r
CC=golang-dev
https://golang.org/cl/1220041
Also: Actual map key must be assignment-compatible with
formal map key type.
Fixes#357.
R=r, iant, rsc, ken2
CC=golang-dev
https://golang.org/cl/673042
This was discussed with Ken and Russ. 6g has been changed,
and both compilers now work this way. This avoids a double
type conversion--first to the float type, then to the complex
type.
R=r
CC=golang-dev, ken2, rsc
https://golang.org/cl/419042
no longer ambiguous at top level, thanks to new semicolon rules.
use gofmt layout for function types.
Fixes#528.
R=gri
CC=golang-dev
https://golang.org/cl/194077
- carriage return is white space
- "" strings cannot span newlines
- f(g()) is ok if g is multivalue and matches f's args
R=rsc, gri
CC=go-dev
http://go/go-review/1024017
- handle HTML tagging via (client-installable) Stylers
go/doc:
- basic styler support
- some factoring
- ready to contain the search code (but for now excluded)
doc/style.css:
- updated
doc/go_spec.css:
- cleanup: replace deprecated uses of <font> tag with <span> tag
R=rsc
DELTA=302 (160 added, 62 deleted, 80 changed)
OCL=35973
CL=35996
- specify evaluation order of floating-point expressions as
discussed
- specify floating point conversion rounding as discussed
- slightly reformatted section on conversions to make it
more readable (hopefully)
- fixed production for interpreted_string_lit - components
were not properly tagged before because of """ instead of `"`
R=go-dev
DELTA=83 (41 added, 11 deleted, 31 changed)
OCL=35864
CL=35885
- the first HTML comment in those files is extracted as page
title when serving them
- lib/godoc.html is top-level template for all pages served
- experimented a bit with package documentation layout
(feedback welcome)
- various related cleanups
TODO:
- The / page (doc/root.html) content repeats links that are
in the navigation bar. It needs to be cleaned up.
R=rsc
DELTA=826 (86 added, 692 deleted, 48 changed)
OCL=35230
CL=35245
- moved Conversions section out of built-in functions and into expressions
- fixed syntax of conversions (parens are not mandatory if the type is not a TypeName)
(this is the only change to the Conversions section; the rest of the text is just moved;
old line: 4043, new line: 3078)
- fixed syntax of composite literals (parens are allowed around LiteralType)
DELTA=239 (115 added, 98 deleted, 26 changed)
OCL=35118
CL=35159
- removed section on Multiple-file packages as this seems now now covered
sufficiently elsewhere
DELTA=45 (11 added, 25 deleted, 9 changed)
OCL=35065
CL=35071
+ style sheet: like code.google.com but less feature-ful
+ JS with table-of-contents generation
+ tweaked go_spec.html and go_mem.html to use new style+JS
+ static-HTML-ified a few other Go docs:
+ static HTML versions of some wiki pages (which I'll turn
into links to these pages).
A notable thing that is _not_ in this changelist: any change
to the godoc tool or whatever thing generates http://go/godoc
R=r
APPROVED=r
DELTA=2472 (2307 added, 113 deleted, 52 changed)
OCL=34644
CL=34728
- added TODO for syntax for built-ins (require type as first argument)
- removed duplicate definition of Index
DELTA=13 (11 added, 1 deleted, 1 changed)
OCL=34668
CL=34688