summaryrefslogtreecommitdiff
path: root/doc/go_spec.html
Commit message (Collapse)AuthorAgeFilesLines
* spec: permit parentheses around builtin function namesRobert Griesemer2014-10-271-11/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not a language change. This is simply documenting the status quo which permits builtin function names to be parenthesized in calls; e.g., both len(s) and (((len)))(s) are accepted by all compilers and go/types. Changed the grammar by merging the details of BuiltinCall with ordinary Calls. Also renamed the Call production to Arguments which more clearly identifies that part of the grammar and also matches better with its counterpart on the declaration side (Parameters). The fact that the first argument can be a type (for builtins) or cannot be a type (for regular function calls) is expressed in the prose, no need to make the grammar more complicated. Fixes issue 9001. LGTM=iant, r, rsc R=r, rsc, iant, ken, dave CC=golang-codereviews https://codereview.appspot.com/160570043
* spec: minimal documention of unsafe.Pointer conversionsRobert Griesemer2014-10-231-5/+6
| | | | | | | | | | | | Per suggestion from rsc as a result of the dicussion of (abandoned) CL 153110044. Fixes issue 7192. LGTM=r, rsc, iant R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/163050043
* spec: define "variable"Robert Griesemer2014-10-161-25/+78
| | | | | | | | | Fixes issue 8496. LGTM=rsc, r, iant R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/148580043
* spec: clarify variable declaration type rulesRobert Griesemer2014-09-301-33/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not a language change. Several inaccuracies were fixed: 1) A variable declaration may declare more than just one variable. 2) Variable initialization follows the rules of assignments, including n:1 assignments. The existing wording implied a 1:1 or n:n rule and generally was somewhat unspecific. 3) The rules for variable declarations with no types and untyped initialization expressions had minor holes (issue 8088). 4) Clarified the special cases of assignments of untyped values (we don't just have untyped constants, but also untyped bools, e.g. from comparisons). The new wording is more direct. To that end, introduced the notion of an untyped constant's "default type" so that the same concept doesn't have to be repeatedly introduced. Fixes issue 8088. LGTM=iant, r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/142320043
* spec: specify variable initialization order explicitlyRobert Griesemer2014-09-291-16/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing spec rules on package initialization were contradictory: They specified that 1) dependent variables are initialized in dependency order, and 2) independent variables are initialized in declaration order. This 2nd rule cannot be satisfied in general. For instance, for var ( c = b + 2 a = 0 b = 1 ) because of its dependency on b, c must be initialized after b, leading to the partial order b, c. Because a is independent of b but is declared before b, we end up with the order: a, b, c. But a is also independent of c and is declared after c, so the order b, c, a should also be valid in contradiction to a, b, c. The new rules are given in form of an algorithm which outlines initialization order explicitly. gccgo and go/types already follow these rules. Fixes issue 8485. LGTM=iant, r, rsc R=r, rsc, iant, ken, gordon.klaus, adonovan CC=golang-codereviews https://codereview.appspot.com/142880043
* spec: clarify scope and re-use of iteration variablesRobert Griesemer2014-09-251-1/+2
| | | | | | | | | Fixes issue 7834. LGTM=iant, rsc, r R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/148940044
* spec: clarify embedding of interfacesRobert Griesemer2014-09-251-12/+19
| | | | | | | | | Fixes issue 7886. LGTM=iant, r, rsc R=r, iant, rsc, ken CC=golang-codereviews https://codereview.appspot.com/149010043
* spec: add dropped commaRob Pike2014-09-191-1/+1
| | | | | | | | | The proposed text in the last CL had a comma that was missing from the submitted spec. LGTM=gri R=gri CC=golang-codereviews https://codereview.appspot.com/150720043
* spec: clarify panic behavior when deferring nil functionsRobert Griesemer2014-09-191-4/+7
| | | | | | | | | Fixes issue 8107. LGTM=iant, rsc, r R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/145960043
* spec: Add link to rune literals from string literals when talking about ↵Robin Eklind2014-09-031-1/+1
| | | | | | | | | | | escape sequences. LGTM=gri R=golang-codereviews, gobot, gri CC=golang-codereviews https://codereview.appspot.com/140750043 Committer: Robert Griesemer <gri@golang.org>
* spec: Fix indentation and remove trailing white space characters.Robin Eklind2014-08-301-9/+9
| | | | | | | | | LGTM=gri R=golang-codereviews, bradfitz, gri CC=golang-codereviews https://codereview.appspot.com/133330043 Committer: Robert Griesemer <gri@golang.org>
* spec: move Method expr/value section near selectorsRobert Griesemer2014-08-281-227/+228
| | | | | | | | | | | | | | | | Preparation for fixing issue 5769 (method selectors do not auto-dereference): The actual fix may require some cleanups in all these sections, and syntactically, method expressions and method values are selector expressions. Moving them next to each other so that it's easy to see the actual changes (next CL). No content changes besides the section moves. LGTM=iant, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/132300043
* spec: comma-ok expressions return untyped boolean 2nd resultRobert Griesemer2014-08-051-15/+10
| | | | | | | | | | | | | | | | | | Technically a language change, this cleanup is a completely backward compatible change that brings the boolean results of comma-ok expressions in line with the boolean results of comparisons: they are now all untyped booleans. The implementation effort should be minimal (less than a handfull lines of code, depending how well factored the implementation of comma-ok expressions is). Fixes issue 8189. LGTM=iant, r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/112320045
* doc: drop scheme from links that are known to support HTTPSAndrew Gerrand2014-07-251-1/+1
| | | | | | | | | | | golang.org now serves HTTPS with a valid cert, so it's reasonable that users should click through to the HTTPS versions of *.golang.org and other known sites. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/112650043
* spec: permit "for range x" (no index variables)Robert Griesemer2014-07-141-15/+19
| | | | | | | | | | | | | | | | | | | | | | This is a fully backward-compatible language change. There are not a lot of cases in the std library, but there are some. Arguably this makes the syntax a bit more regular - any trailing index variable that is _ can be left away, and there's some analogy to type switches where the temporary can be left away. Implementation-wise the change should be trivial as it can be done completely syntactically. For instance, the respective change in go/parser is a dozen lines (see https://codereview.appspot.com/112970044 ). Fixes issue 6102. LGTM=iant, r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/104680043
* spec: receiver declaration is just a parameter declarationRobert Griesemer2014-06-241-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL removes the special syntax for method receivers and makes it just like other parameters. Instead, the crucial receiver-specific rules (exactly one receiver, receiver type must be of the form T or *T) are specified verbally instead of syntactically. This is a fully backward-compatible (and minor) syntax relaxation. As a result, the following syntactic restrictions (which are completely irrelevant) and which were only in place for receivers are removed: a) receiver types cannot be parenthesized b) receiver parameter lists cannot have a trailing comma The result of this CL is a simplication of the spec and the implementation, with no impact on existing (or future) code. Noteworthy: - gc already permits a trailing comma at the end of a receiver declaration: func (recv T,) m() {} This is technically a bug with the current spec; this CL will legalize this notation. - gccgo produces a misleading error when a trailing comma is used: error: method has multiple receivers (even though there's only one receiver) - Compilers and type-checkers won't need to report errors anymore if receiver types are parenthesized. Fixes issue 4496. LGTM=iant, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/101500044
* spec: clarify that break/continue do not work across function boundariesRobert Griesemer2014-05-281-3/+6
| | | | | | | | | | | | Also made it extra clear for goto statements (even though label scopes are already limited to the function defining a label). Fixes issue 8040. LGTM=r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/99550043
* spec: explicitly disallow blank methods in interface typesRobert Griesemer2014-05-221-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec was unclear about whether blank methods should be permitted in interface types. gccgo permits at most one, gc crashes if there are more than one, go/types permits at most one. Discussion: Since method sets of non-interface types never contain methods with blank names (blank methods are never declared), it is impossible to satisfy an interface with a blank method. It is possible to declare variables of assignable interface types (but not necessarily identical types) containing blank methods, and assign those variables to each other, but the values of those variables can only be nil. There appear to be two "reasonable" alternatives: 1) Permit at most one blank method (since method names must be unique), and consider it part of the interface. This is what appears to happen now, with corner-case bugs. Such interfaces can never be implemented. 2) Permit arbitrary many blank methods but ignore them. This appears to be closer to the handling of blank identifiers in declarations. However, an interface type literal is not a declaration (it's a type literal). Also, for struct types, blank identifiers are not ignored; so the analogy with declarations is flawed. Both these alternatives don't seem to add any benefit and are likely (if only slightly) more complicated to explain and implement than disallowing blank methods in interfaces altogether. Fixes issue 6604. LGTM=r, rsc, iant R=r, rsc, ken, iant CC=golang-codereviews https://codereview.appspot.com/99410046
* spec: specify order of init() callsgo1.3beta2Robert Griesemer2014-05-201-1/+2
| | | | | | | | | | | | | | | | | | | The spec did not specify the order in which init() functions are called. Specify that they are called in source order since we have now also specified the initialization order of independent variables. While technically a language change, no existing code could have relied on this, so this should not break anything. Per suggestion from rsc. LGTM=r, iant R=rsc, iant, r, ken CC=golang-codereviews https://codereview.appspot.com/98420046
* spec: clarify section on package initializationRobert Griesemer2014-05-201-54/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - split description of package initialization and program execution - better grouping of concerns in section on package initialization - more explicit definition of what constitues a dependency - removed language about constant dependencies - they are computed at compile-time and not initialized at run-time - clarified that independent variables are initialized in declaration order (rather than reference order) Note that the last clarification is what distinguishes gc and gccgo at the moment: gc uses reference order (i.e., order in which variables are referenced in initialization expressions), while gccgo uses declaration order for independent variables. Not a language change. But adopting this CL will clarify what constitutes a dependency. Fixes issue 6703. LGTM=adonovan, r, iant, rsc R=r, rsc, iant, ken, adonovan CC=golang-codereviews https://codereview.appspot.com/99020043
* doc/go_spec.html: fix broken anchor tagRob Pike2014-05-201-1/+1
| | | | | | | LGTM=gri R=gri CC=golang-codereviews https://codereview.appspot.com/99420045
* spec: clarify when a program exitsRobert Griesemer2014-05-191-2/+2
| | | | | | | | | Fixes issue 8023. LGTM=rsc R=r, iant, ken, rsc CC=golang-codereviews https://codereview.appspot.com/98340043
* spec: clarify that newlines are kept in raw string literalsIan Lance Taylor2014-05-161-1/+1
| | | | | | | | | Fixes issue 8007. LGTM=r R=gri, r CC=golang-codereviews https://codereview.appspot.com/91510044
* spec: more precise description of select statementRobert Griesemer2014-05-141-33/+63
| | | | | | | | | | | | | | | | | | | | - use previously defined terms (with links) throughout - specify evaluation order more precisely (in particular, the evaluation time of rhs expressions in receive cases was not specified) - added extra example case Not a language change. Description matches observed behavior of code compiled with gc and gccgo. Fixes issue 7669. LGTM=iant, r, rsc R=r, rsc, iant, ken, josharian CC=golang-codereviews https://codereview.appspot.com/91230043
* spec: several clarifications to language on channelsRobert Griesemer2014-05-071-34/+38
| | | | | | | | | | | | | | | | | | | - A channel may be used between any number of goroutines, not just two. - Replace "passing a value" (which is not further defined) by "sending and receiving a value". - Made syntax production more symmetric. - Talk about unbuffered channels before buffered channels. - Clarify what the comma,ok receive values mean (issue 7785). Not a language change. Fixes issue 7785. LGTM=rsc, r, iant R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/94030045
* spec: remove evaluation order inconsistencyRobert Griesemer2014-05-071-6/+31
| | | | | | | | | | | | This is a clarification of what happens already. Not a language change. Fixes issue 7137. LGTM=iant, r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/96000044
* spec: clarify type propertiesRobert Griesemer2014-05-071-4/+4
| | | | | | | | | | | | | | | If the underlying type of a type T is a boolean, numeric, or string type, then T is also a boolean, numeric, or string type, respectively. Not a language change. Fixes issue 7551. LGTM=iant, rsc, robert.hencke, r R=r, rsc, iant, ken, robert.hencke CC=golang-codereviews https://codereview.appspot.com/100130044
* doc: replace absolute links to golang.org with relative linksDmitriy Vyukov2014-05-071-1/+1
| | | | | | | | | | Currently tip.golang.org leads to golang.org and local godoc also leads to golang.org (when you don't have internet connectivity). LGTM=crawshaw R=golang-codereviews, crawshaw CC=golang-codereviews https://codereview.appspot.com/100200043
* spec: clarify when constant slice indices must be in rangeRobert Griesemer2014-03-061-3/+3
| | | | | | | | | | | | This documents the status quo for most implementations, with one exception: gc generates a run-time error for constant but out-of-range indices when slicing a constant string. See issue 7200 for a detailed discussion. LGTM=r R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/72160044
* spec: clarify value passed for final parameter of variadic functionsRobert Griesemer2014-03-061-10/+15
| | | | | | | | | | | NOT A LANGUAGE CHANGE. Fixes issue 7073. LGTM=r R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/68840045
* spec: be more precise about underlying types of predeclared typesRobert Griesemer2014-03-051-2/+3
| | | | | | | | | | | | The underlying type of the predeclared type error is not itself, but the interface it is defined as. Fixes issue 7444. LGTM=r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/71790044
* spec: shadowed return parameters may be disallowedRobert Griesemer2014-03-051-1/+16
| | | | | | | | | | | | | | This documents the implemented behavior of both gc and gccgo as an implementation restriction. NOT A LANGUAGE CHANGE. Fixes issue 5425. LGTM=rsc, r, iant R=r, iant, rsc, ken CC=golang-codereviews https://codereview.appspot.com/71430043
* spec: clarify what is considered a function call for len/cap special caseRobert Griesemer2014-03-031-2/+12
| | | | | | | | | | | | | | | | | | | | | gccgo considers built-in function calls returning a constant not as function call (issue 7386) go/types considers any call (regular or built-in) as a function call The wording and examples clarify that only "function calls" that are issued at run-time (and thus do not result in a constant result) are considered function calls in this case. gc is inconsistent (issue 7385) gccgo already interprets the spec accordingly and issue 7386 is moot. go/types considers all calls (constant or not) as function calls (issue 7457). Fixes issue 7387. Fixes issue 7386. LGTM=r, rsc, iant R=r, rsc, iant, ken CC=golang-codereviews https://codereview.appspot.com/66860046
* spec: slightly rephrased wording on parsing ambiguity for composite literalsRobert Griesemer2014-02-271-10/+8
| | | | | | | | | Fixes issue 4482. LGTM=r R=r, iant, rsc, ken CC=golang-codereviews https://codereview.appspot.com/69020045
* spec: libraries and implementation are now at Unicode 6.3Rob Pike2014-02-251-2/+2
| | | | | | | LGTM=gri R=gri CC=golang-codereviews https://codereview.appspot.com/68760043
* spec: clarify default "true" condition/tag in for/switch statementsRobert Griesemer2014-02-251-5/+7
| | | | | | | | | | | | | | | An absent condition/tag in for and switch statements is equivalent to the predeclared constant true; not simply the expression true (which might lead to a locally defined true). Not a language change. Fixes issue 7404. LGTM=iant, r R=r, iant, rsc, ken CC=golang-codereviews https://codereview.appspot.com/68150046
* spec: tighten the wording around . importsRob Pike2014-01-141-3/+3
| | | | | | | | Make it clear that if you do a . import, you cannot use a qualified identifier. R=gri CC=golang-codereviews https://codereview.appspot.com/52390043
* spec: s/and/or/ for correctness and parallelismRob Pike2014-01-041-2/+2
| | | | | | | | | | No change to the meaning, just bad writing found by Doug McIlroy. Let's start the new year off with a bang. R=golang-codereviews, bradfitz, dave CC=golang-codereviews https://codereview.appspot.com/47110044
* spec: Fix broken type identity linkEmil Hessman2014-01-031-1/+1
| | | | | | | | | | Fixes issue 7003. R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/47780043 Committer: Brad Fitzpatrick <bradfitz@golang.org>
* spec: example shows wrong value for complex constantMihai Borobocea2013-12-301-1/+1
| | | | | | | | | | | Looks like a typo. Fixes issue 7011. R=golang-codereviews, r, bradfitz CC=golang-codereviews https://codereview.appspot.com/45350043 Committer: Brad Fitzpatrick <bradfitz@golang.org>
* spec: clarify rules for blank identifiersRobert Griesemer2013-11-121-27/+55
| | | | | | | | | | | | | This documents the status quo more precisely. Not a language change. Fixes issue 6006. R=r, rsc, iant, ken CC=golang-dev https://codereview.appspot.com/14415043 Committer: Russ Cox <rsc@golang.org>
* spec: clarify re-use of underlying arrays in slice operationsRobert Griesemer2013-10-161-21/+14
| | | | | | | | | | | | | | | | Please note the slight rewording for append: The spec now requires that append reuses the underlying array if it is sufficiently large. Per majority sentiment. This is technically a language change but the current implementation always worked this way. Fixes issue 5818. Fixes issue 5180. R=rsc, iant, r, ken, minux.ma, dan.kortschak, rogpeppe, go.peter.90 CC=golang-dev https://codereview.appspot.com/14419054
* spec: unsafe.Pointers are pointersRobert Griesemer2013-10-071-1/+5
| | | | | | | | | | | But they cannot be dereferenced. See also issue 6116. Fixes issue 6358. R=r, rsc, iant, ken CC=golang-dev https://codereview.appspot.com/14374046
* doc: move spec and memory model back to /ref/Andrew Gerrand2013-10-041-1/+1
| | | | | | R=golang-dev, r CC=golang-dev https://codereview.appspot.com/14364043
* spec: added additional links, added missing 'label'Robert Griesemer2013-10-031-6/+11
| | | | | | | | No semantic spec changes. R=r CC=golang-dev https://codereview.appspot.com/14363043
* spec: fix small typo in comment for exampleRobert Hencke2013-10-031-2/+2
| | | | | | | | R=golang-dev, mirtchovski, r CC=golang-dev https://codereview.appspot.com/14227043 Committer: Rob Pike <r@golang.org>
* spec: add example for continue to labelRob Pike2013-09-171-8/+26
| | | | | | | | | | Make the break example slightly more interesting Update issue 5725 Effective Go will be updated in a separate CL. R=golang-dev, iant CC=golang-dev https://codereview.appspot.com/13368054
* doc: re-organize golang.org site contentAndrew Gerrand2013-09-161-1/+1
| | | | | | | | | | | | | | | | | | | | Remove "References" section. Remove most articles and redirect to blog.golang.org. Move /ref/spec and /ref/mem to /doc/spec and /doc/mem. Remove duplicate links from the remaining "Documents", "The Project", and "Help" pages. Defer to the wiki for more links and community content. Update command reference and mention cover tool. Add "Pop-out" text to the front page. Pick one of four videos at random to feature on the front page. Fixes issue 2547. Fixes issue 5561. Fixes issue 6321. R=r, dominik.honnef CC=golang-dev https://codereview.appspot.com/13724043
* spec: define s[i:j:k]Robert Griesemer2013-09-111-4/+61
| | | | | | R=rsc, r, iant, ken CC=golang-dev https://codereview.appspot.com/10243046
* spec: &x panics if x doesRuss Cox2013-08-151-0/+7
| | | | | | | | See golang.org/s/go12nil for the extended version. R=golang-dev, r, adonovan CC=golang-dev https://codereview.appspot.com/12964043