1
0
mirror of https://github.com/golang/go synced 2024-10-03 12:21:22 -06:00
Commit Graph

496 Commits

Author SHA1 Message Date
Robert Hencke
58d18e25af spec: fix small typo in comment for example
R=golang-dev, mirtchovski, r
CC=golang-dev
https://golang.org/cl/14227043
2013-10-03 12:46:02 -07:00
Rob Pike
cec0954dd0 spec: add example for continue to label
Make the break example slightly more interesting
Update #5725
Effective Go will be updated in a separate CL.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13368054
2013-09-17 07:41:11 +10:00
Andrew Gerrand
5dd74175d4 doc: re-organize golang.org site content
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 #2547.
Fixes #5561.
Fixes #6321.

R=r, dominik.honnef
CC=golang-dev
https://golang.org/cl/13724043
2013-09-16 15:47:13 +10:00
Robert Griesemer
e333b96529 spec: define s[i:j:k]
R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/10243046
2013-09-11 17:18:52 -07:00
Russ Cox
5ce78b7cd2 spec: &x panics if x does
See golang.org/s/go12nil for the extended version.

R=golang-dev, r, adonovan
CC=golang-dev
https://golang.org/cl/12964043
2013-08-15 14:33:26 -04:00
Rob Pike
15e6ce2351 go_spec.html: clarify that tags are part of struct type identity
One sentence says they're ignored, another says they take part.
Fix the first.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12741046
2013-08-15 13:15:55 +10:00
Robert Griesemer
2961d229de spec: clarify index and selector expressions
(Replacement for CL 11884043.)

1) Explain a[i] and a[i:j] where a is of type *A as
   shortcut for (*a)[i] and (*a)[i:j], respectively.

2) Together with 1), because len() of nil slices is
   well defined, there's no need to special case nil
   operands anymore.

3) The result of indexing or slicing a constant string
   is always a non-constant byte or string value.

4) The result of slicing an untyped string is a value
   of type string.

5) If the operand of a valid slice a[i:j] is nil (i, j
   must be 0 for it to be valid - this already follows
   from the in-range rules), the result is a nil slice.

Fixes #4913.
Fixes #5951.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/12198043
2013-07-31 22:25:47 -07:00
Rob Pike
bd65404eef spec: clarify a couple of issues about channels
1. They are FIFOs.
2. They are safe for concurrent access.

Fixes #5911.

R=golang-dev, dvyukov, adg
CC=golang-dev
https://golang.org/cl/11549043
2013-08-01 07:12:32 +10:00
Robert Griesemer
9f75dd7f25 undo CL 11884043 / bfd5ed8236d5
CL submitted prematurely by mistake.

««« original CL description
spec: clarify index and selector expressions

1) Explain a[i] and a[i:j] where a is of type *A as
   shortcut for (*a)[i] and (*a)[i:j], respectively.

2) Together with 1), because len() of nil slices is
   well defined, there's no need to special case nil
   operands anymore.

3) The result of indexing or slicing a constant string
   is always a non-constant byte or string value.

4) The result of slicing an untyped string is a value
   of type string.

5) If the operand of a valid slice a[i:j] is nil (i, j
   must be 0 for it to be valid - this already follows
   from the in-range rules), the result is a nil slice.

Fixes #4913.
Fixes #5951.

R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/11884043
»»»

R=r
CC=golang-dev
https://golang.org/cl/12170046
2013-07-31 14:10:46 -07:00
Robert Griesemer
58d2960655 spec: clarify index and selector expressions
1) Explain a[i] and a[i:j] where a is of type *A as
   shortcut for (*a)[i] and (*a)[i:j], respectively.

2) Together with 1), because len() of nil slices is
   well defined, there's no need to special case nil
   operands anymore.

3) The result of indexing or slicing a constant string
   is always a non-constant byte or string value.

4) The result of slicing an untyped string is a value
   of type string.

5) If the operand of a valid slice a[i:j] is nil (i, j
   must be 0 for it to be valid - this already follows
   from the in-range rules), the result is a nil slice.

Fixes #4913.
Fixes #5951.

R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/11884043
2013-07-31 13:40:01 -07:00
Robert Griesemer
f331012427 spec: update prose in Constants section
Fixes #5952.

R=r, rsc
CC=golang-dev
https://golang.org/cl/11812043
2013-07-25 09:35:55 -07:00
Robert Griesemer
63f54ae3c2 spec: move decl in example closer to use
Fixes #5862.

R=r
CC=golang-dev
https://golang.org/cl/11168043
2013-07-11 14:41:46 -07:00
Robert Griesemer
8268eadb9e spec: define notion of named type
The notion of a named type is crucial for the definition
of type identity, assignability, definitions of methods.
Explicitly introduce the notion with an extra sentence.

Fixes #5682.

R=r, rsc, iant
CC=golang-dev
https://golang.org/cl/11055043
2013-07-09 21:12:53 -07:00
Robert Griesemer
de47f68c99 spec: fix spec on conversions to match implementations
The existing compilers convert empty strings to empty
but non-nil byte and rune slices. The spec required
a nil byte and rune slice in those cases. That seems
an odd additional requirement. Adjust the spec to
match the reality.

Also, removed over-specification for conversions of
nil []byte and []rune: such nil slices already act
like empty slices and thus don't need extra language.
Added extra examples instead.

Fixes #5704.

R=rsc, r, iant
CC=golang-dev
https://golang.org/cl/10440045
2013-06-21 16:11:13 -07:00
Shenghou Ma
bdac989ef7 doc/go_spec: more examples for unspecified cases of the evaluation order
R=golang-dev, bradfitz, gri, iant, rsc
CC=golang-dev
https://golang.org/cl/7235044
2013-06-11 02:52:07 +08:00
Robert Griesemer
ab5c762a46 spec: better wording re: receiving from closed channels
As suggested by ej@evanjones.ca.

Fixes #5604.

R=r
CC=golang-dev
https://golang.org/cl/9899043
2013-05-31 11:21:37 -07:00
Robert Griesemer
6a3859f433 spec: removed old or invalid TODOs
Several old TODOs are either resolved now (e.g. when is a return
needed), or are from a time the language wasn't frozen (^ for uints
only). Consolidated the others.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9599044
2013-05-20 14:01:07 -07:00
Robert Griesemer
bb3a32ef6e spec: fix language about "range" clause
Fixes #5434.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/9595044
2013-05-20 13:27:53 -07:00
Shenghou Ma
df29cdd33d doc/go_spec: fix typos
Fixes #5456.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9400044
2013-05-15 03:50:27 +08:00
Robert Griesemer
2d846f6521 spec: fix incorrect example
Fixes #5430.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9305043
2013-05-08 10:42:08 -07:00
Rob Pike
548c65a568 spec: add another sentence about BOMs
Although one may argue that they should be legal, gc (at least)
disallows byte order marks that are not the first code point
in the file. Added a sentence to the "Implementation restriction"
clause in the "Source code representation" section to document
this better.

Lifting this restriction (again - the rule has changed at least
twice already) would not break any existing programs, should
we later decide yet again to fiddle the rules about these little
fly specks.

R=golang-dev, dsymonds, gri
CC=golang-dev
https://golang.org/cl/8649043
2013-04-11 11:33:25 -07:00
Robert Griesemer
b34f055138 spec: Go has no 'reference types'
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8288044
2013-04-02 23:17:37 -07:00
Robert Griesemer
462a17e0f3 spec: remove most §links for the now more common in-text links
Also:
- more consistenly use "xxx" statement rather than <code>xxx</code> statement
- fix/remove unnecessary links

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7821050
2013-03-22 15:36:04 -07:00
Rob Pike
d02089101c spec: add example showing missing return statement
Will help people find the rules by searching the spec by
having a comment saying "missing return";
"terminating statement" does not evoke the rule to the
uninitiated.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7838044
2013-03-22 10:03:55 -07:00
Rob Pike
b636f192e2 spec: fix description of initialization
The analysis does not depend on the values of the items.
Fixes #4648.

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/7593050
2013-03-20 15:05:28 -07:00
Russ Cox
6e15683cae spec: define method values
Fixes #2280.

R=golang-dev, r, bradfitz, iant, andybalholm, gri
CC=golang-dev
https://golang.org/cl/7816045
2013-03-20 16:54:07 -04:00
Robert Griesemer
58e21ddaf9 spec: remove special int rule for shifts
The rule is not concistently followed by gc.
It appears that gccgo is ignoring it. go/types
does not implement this rule. However, both
gccgo and now go/types can compile/type-check
the entire std library (and thus all the shift
expressions occuring in it) w/o errors. For
more details see the discussion in issue 4883.

Fixes #4880.
Fixes #4881.
Fixes #4883.

R=rsc, r, iant, ken, ken, mtj, rogpeppe
CC=golang-dev
https://golang.org/cl/7707043
2013-03-15 13:55:50 -07:00
Rob Pike
c34050fd53 spec: rewrite the description of panic and recover.
The old description was misleading and inaccurate.

Fixes #4774.

R=iant, rsc, gri
CC=golang-dev
https://golang.org/cl/7761044
2013-03-12 14:28:16 -07:00
Robert Griesemer
b66df0e9ba spec: typed indices must be of integer type
The same rules apply for make arguments.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/7656043
2013-03-11 09:20:52 -07:00
Robert Griesemer
c729ed631f spec: result type of a comparison is always untyped bool
For details see the cited issue.

Fixes #4793.

R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/7524044
2013-03-11 09:16:29 -07:00
Robert Griesemer
51338095eb spec: clarify unsafe.Offsetof
Fixes #4905.

R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/7583043
2013-03-07 20:11:37 -08:00
Robert Griesemer
9905cec0dc spec: terminating statements for functions
The only functional change is the new section
on terminating statements.

There is a minor syntax rewrite (not change)
of function declarations to make it easier to
refer to the notion of a function from all places
where it is used (function decls, method decls,
and function literals).

Includes some minor fixes/additions of missing links.

Based closely on Russ' proposal.

Fixes #65.

R=rsc, r, iant, ken, bradfitz
CC=golang-dev
https://golang.org/cl/7415050
2013-03-04 13:55:35 -08:00
Robert Griesemer
4be38dde84 spec: cyclic imports are illegal
Fixes #4976.

R=r
CC=golang-dev
https://golang.org/cl/7421050
2013-03-04 12:59:40 -08:00
Robert Griesemer
67a6b4f0ef spec: fallthrough may not appear in last clause of a switch
Replacement for CL 7370053 which attempted to make fallthrough's
syntactically a part of switch statements. Because they may be
labeled, fixing that CL completely would require too much spec
surgery.

Fixes #4923.

R=r, iant, rsc, ken
CC=golang-dev
https://golang.org/cl/7416048
2013-03-01 16:45:14 -08:00
Rob Pike
7ae41e8010 doc: correct some minor HTML errors found by tidy
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7439046
2013-02-28 13:32:36 -08:00
Russ Cox
61e02ee901 spec: clarify when range x does not evaluate x
Fixes #4644.

R=r, adonovan
CC=golang-dev
https://golang.org/cl/7307083
2013-02-15 14:39:28 -05:00
Russ Cox
71c941b6f6 spec: only require parens around ambiguous conversions
This is documenting the status quo. The previous cleanup
added this language as an implementation restriction, but
at least for now it is really part of the language proper.

Fixes #4605.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7305071
2013-02-11 07:48:14 -05:00
Russ Cox
7576179aa3 spec: document fp rounding during explicit constant conversion
The gc compilers already behave this way. It was an explicit
decision during the very long constant design discussions,
but it appears not to have made it into the spec.

Fixes #4398.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7313069
2013-02-11 07:47:41 -05:00
Russ Cox
0a22018d46 spec: reject top-level init names
Fixes #4586.

R=golang-dev, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/7307082
2013-02-11 07:46:39 -05:00
Russ Cox
81eb930f7e spec: clarify that any unsafe.Pointer type is okay in conversion
The spec is not clear about whether this is allowed or not,
but both compilers allow it, because the reflect implementation
takes advantage of it. Document current behavior.

Fixes #4679.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7303064
2013-02-09 17:36:31 -05:00
Russ Cox
1b3083e68d spec: clarify that f(g()) requires that g return >= 1 value
Fixes #4573.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7322043
2013-02-09 14:46:55 -05:00
Oling Cat
018e89fa69 doc/go_spec: remove extra space, align tags, and change a tab to a space.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7198048
2013-01-24 20:46:33 +11:00
Shenghou Ma
a0b5b46ae4 doc/go_spec: cap doesn't apply to maps
Fixes #4682.

R=golang-dev, adg, dave
CC=golang-dev
https://golang.org/cl/7094062
2013-01-22 03:18:20 +08:00
Robert Griesemer
d3679726b4 spec: clarify lhs syntax for range and select
Fixes #4653.

R=rsc, r, iant, ken, thakis
CC=golang-dev
https://golang.org/cl/7135058
2013-01-18 13:59:25 -08:00
Shenghou Ma
ced57153df doc/go_spec.html: clarification about insertion during map iteration
R=mdempsky, iant, r, gri, rsc, ken
CC=golang-dev
https://golang.org/cl/7100046
2013-01-17 23:11:25 +08:00
Robert Griesemer
f1cc0f44e3 spec: clarify short variable declaration corner cases
Fixes #4612.

R=rsc, iant, ken, r
CC=golang-dev
https://golang.org/cl/7076043
2013-01-09 11:31:32 -08:00
Robert Griesemer
c863db4e87 spec: s/char_lit/rune_lit/
The spec talks explicitly about rune literals but the
respective production is still called char_lit for
historic reasons. Updated the two occurences.

Fixes #4602.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/7070048
2013-01-07 18:02:58 -08:00
Matthew Dempsky
80a87a99cc spec: Use "non-negative" instead of "positive"
Replacing division-by-power-of-2 with right-shift is valid for
zero too.

R=gri
CC=golang-dev
https://golang.org/cl/7027049
2013-01-06 16:56:06 -08:00
Robert Griesemer
614b02d22a spec: clarify language about unary operator &
A composite literal may be parenthesized when
used as operand for the unary operator &.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6996053
2013-01-02 18:11:49 -08:00
Robert Griesemer
462860bd8d spec: more explicit comments for constant expression examples
Fixes #3814.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6920057
2012-12-12 14:25:40 -08:00
Robert Griesemer
a9a49fe962 spec: calling delete on a nil map is a no-op
This is language change. It is a backward-compatible
change but for code that relies on a run-time panic
when calling delete on a nil map (unlikely).

Fixes #4253.

R=rsc, r, iant, ken, bradfitz, rogpeppe
CC=golang-dev
https://golang.org/cl/6909060
2012-12-12 13:08:35 -08:00
Robert Griesemer
3906706297 spec: index and array/slice size constants must fit into an int
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6903048
2012-12-12 11:06:26 -08:00
Robin Eklind
1d46fc44b7 spec: Correct typo in method expressions example.
Also, remove unnecessary whitespace.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6928045
2012-12-11 12:17:53 -05:00
Robert Griesemer
9c9e811bb3 spec: consistently use "indices" (rather than "indexes")
We have been using all three terms "indices", "indexes",
and "index expressions" indiscriminatly for index values.
With this change, "index" refers to an index value,
"indices" is the plural of "index", and "index expression"
refers to an array, slice, or map indexed by an index: a[x].

R=r, rsc, iant, ken, mtj
CC=golang-dev
https://golang.org/cl/6912056
2012-12-10 11:55:57 -08:00
Robert Griesemer
e06d90136f spec: receiver types in method expressions can be parenthesized
Fixes #4457.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6862046
2012-12-06 09:31:42 -08:00
Robert Griesemer
485673188d spec: type assertions and type switches must be valid
The spec didn't preclude invalid type assertions and
type switches, i.e., cases where a concrete type doesn't
implement the interface type in the assertion in the first
place. Both, the gc and gccgo compiler exclude these cases.
This is documenting the status quo.

Also:
- minor clean up of respective examples
- added sentence about default case in select statements

Fixes #4472.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6869050
2012-12-06 09:17:20 -08:00
Robert Griesemer
458632a21a spec: BuiltinCall syntax must permit "..." for append
Also: fix an incorrect link.

Fixes #4479.
Fixes #4456.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6868062
2012-12-04 13:09:02 -08:00
Robert Griesemer
cc3f21cefe spec: channel operations are restricted by the channel direction
Also:
- 'for' statements with a range clause do not accept send-only
   channels
- '_, _ = range ch' is not equivalent to "_ = range ch" if ch
   is a channel (rewriting the latter to the former leads to
   an invalid range clause).

These clarifications document the status quo.

R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/6874053
2012-12-03 14:23:41 -08:00
Robert Griesemer
85e451e2fe go spec: receiver, parameter, and result names must always be unique
Fixes #4450.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6845104
2012-11-29 14:47:47 -08:00
Robert Griesemer
25dd00295c spec: clarify use of built-ins in go/defer statements
1) Built-ins are restricted like for expression statements.
   This documents the status quo.

2) Calls cannot be parenthesized. The spec is not clear. gccgo
   permits it already, gc doesn't. Be explicit in the spec.

 Fixes #4462.

R=rsc, iant, r, ken, lvd
CC=golang-dev
https://golang.org/cl/6861043
2012-11-29 11:46:25 -08:00
Russ Cox
d4f3185c24 spec: add () to method calls in examples
Since p.M is rejected (must call methods), use p.M(),
to keep the examples compiling.

Fixes #4441.

R=gri
CC=golang-dev
https://golang.org/cl/6854096
2012-11-26 15:43:32 -05:00
Robert Griesemer
e126763045 spec: be clearer about the scope of a package name
We have the notion of a PackageName, not package identifier.
As is, it could construed that imports that rename a package
don't have an "imported package identifier" but a local one.

R=r, rsc, iant, ken, dsymonds
CC=golang-dev
https://golang.org/cl/6858049
2012-11-21 14:40:50 -08:00
Robert Griesemer
2ae61d557a spec: fix constant expression example
Fixes #4400.

R=r, mirtchovski
CC=golang-dev
https://golang.org/cl/6782084
2012-11-17 11:16:07 -08:00
Oling Cat
002103f51c spec: we're now at Unicode 6.2.0
R=golang-dev
CC=golang-dev
https://golang.org/cl/6818083
2012-11-01 22:57:01 -07:00
Robert Griesemer
1e8e14c901 spec: clarify returns, defer statements, and panics
This is an attempt at making the interaction between
these three constructs clearer. Specifically:

- return statements terminate a function, execute deferred
  functions, return to the caller, and then execution
  continues after the call

- panic calls terminate a function, execute deferred
  functions, return to the caller, and then re-panic

- deferred functions are executed before a function _returns_
  to its caller

The hope is that with this change it becomes clear when a
deferred function is executed (when a function returns),
and when it is not (when a program exits).

R=r, rsc, iant, ken, iant
CC=golang-dev
https://golang.org/cl/6736071
2012-11-01 10:13:48 -07:00
Robert Griesemer
369a974b41 spec: slight wording change to remove a formal contradiction
Fixes #4324.

R=r
CC=golang-dev
https://golang.org/cl/6822062
2012-10-31 15:07:25 -07:00
Rob Pike
7ea65e5154 spec: we're now at Unicode 6.2.0
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812060
2012-10-31 10:32:15 -07:00
Robert Griesemer
ddddd39fc8 go spec: constant divisors must not be zero
Both gc and gccgo always checked this for constant
expressions but the spec only mentions run-time
exceptions.

This CL also requires that constant divisors
must not be zero in non-constant integer expressions:
This is consistent with the spirit of the most
recent changes and it is consistent with constant
expressions. We don't want to specify the effect for
non-integer expressions (f/0.0 where f is a float or
complex number) because there the result f/g is not
further specified if a non-constant g is 0.

R=r, rsc, iant, ken, andybalholm, iant
CC=golang-dev
https://golang.org/cl/6710045
2012-10-19 10:12:09 -07:00
Robert Griesemer
3bde00033b go spec: define make() restrictions as for index expressions
This is a language change: Until now, the spec required run-
time panics for some of these errors. Note that gc and gccgo
implemented this inconsistently, and that both compilers already
reported compile-time errors in some cases. This change makes
make() behave along the same vein as index expressions.

This addresses the spec aspect of issue 4085.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6725053
2012-10-19 10:11:06 -07:00
Robert Griesemer
ea7c57a031 go spec: restrictions for index and slice expressions
At the moment, gc and gccgo report compile-
time errors for certain constant indexes that
are out of bounds. The spec however requests
a run-time panic for out-of-bounds indexes
(http://tip.golang.org/ref/spec#Indexes).

Document the status quo.

Fixes #4231.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6699048
2012-10-17 11:08:42 -07:00
Rob Pike
15970c8d6d spec: more clarification about deferred functions
Proposed new text to make matters clearer. The existing text was
unclear about the state of result parameters when panicking.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6653047
2012-10-16 11:27:20 +11:00
Rob Pike
f04ae1373e spec: clarify defer semantics
It's already there but only in the "for instance" and so not
clear enough: deferred functions run after
the result parameters are updated.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6631058
2012-10-10 13:29:50 +11:00
Robert Griesemer
3188ffc931 go spec: conversion types starting with "func" must be parenthesized
Also: Be explicit what operator means with respect to conversion types.

The parenthesis requirement is a language change. At the moment,
literal function types in conversions that cannot possibly be
followed by a '(' don't need parentheses. For instance:

        func(int)int(x)  ->  same as (func(int)int)(x)
        func()()(x)      ->  same as (func())(x)

but:

        func(int)(x)	 ->  could be func(int)x {...}

Fixes #4109.

R=rsc, r, iant, ken, iant
CC=golang-dev
https://golang.org/cl/6584065
2012-10-03 13:46:37 -07:00
Robert Griesemer
0c494718af go spec: arguments for append may overlap
Fixes #4142.

R=rsc, r, iant, ken, remyoudompheng
CC=golang-dev
https://golang.org/cl/6567062
2012-09-28 15:55:38 -07:00
Robert Griesemer
60a6ae8c3c spec: permit trailing comma in conversions
Also: Adjust prose in Conversions section
to be consistent.

This is a backward-compatible syntax change.
For a discussion see issue 2568.

Fixes #2568.
Fixes #4123.

R=golang-dev, r, iant, rsc
CC=golang-dev
https://golang.org/cl/6572049
2012-09-26 10:31:57 -07:00
Rob Pike
b51ad9cf45 spec: a couple of minor tweaks to the wording of the import section
- remove ambiguous 'it'
- use a lower-case PackageName in the example

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6552057
2012-09-23 05:03:43 +10:00
Robert Griesemer
8c058b32d1 spec: clarify expression statements
Function and method calls are valid expression statements,
but calling certain built-in functions is not permitted.
Enumerate the built-ins.

Also: unsafe.Offsetof permits parenthesized selectors as
arguments.

This is simply documenting existing compiler behavior
(both gc and gccgo agree).

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6498138
2012-09-18 11:25:53 -07:00
Robert Griesemer
c7631f555f spec: unsafe.Alignof/Sizeof also accept non-variable arguments
Both gc and gccgo permit calls such as unsafe.Sizeof(42). The
spec only permits variable arguments. This is a (backward-compatible)
spec change reflecting the status quo. Seems preferrable over
restricting the compilers.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6494140
2012-09-17 12:23:41 -07:00
Robert Griesemer
cc06593c68 spec: clarify section on string types
Strings happen to be represented similarly to
byte slices internally, but they don't quite
behave like them: While strings can be indexed,
sliced, and have their len() taken like byte
slices, string elements are not addressable,
make() and cap() is not supported, range loops
operate differently, and they are immutable (and
thus behave like values rather then references).

Fixes #4018.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6503116
2012-09-14 11:31:56 -07:00
Russ Cox
1b4e37a43c spec: make bitwise operators stand out
The (and not) arguably sounds like it is trying to say something - and not what?.

Just an idea, won't be hurt if it gets rejected.

R=gri, dsymonds, r
CC=golang-dev
https://golang.org/cl/6498115
2012-09-12 12:05:24 -04:00
Rob Pike
488350ac42 spec: an initial BOM can be ignored
After further deliberation, let's back down to the Unicode proposal.
Ignoring aBOMinations anywhere means that things like
        grep unsafe *.go
might fail because there's a BOM in the middle: unBOMsafe.

R=golang-dev, rsc, 0xjnml, gri, bradfitz
CC=golang-dev
https://golang.org/cl/6490091
2012-09-07 10:28:24 -07:00
Rob Pike
afac01df48 spec: ignore BOMS outside of string and rune literals.
Happy Birthday UTF-8.

R=golang-dev, rsc, 0xjnml
CC=golang-dev
https://golang.org/cl/6506083
2012-09-06 10:37:13 -07:00
Oling Cat
845f4d6b47 doc/go_spec: fix a typo
R=nigeltao
CC=golang-dev
https://golang.org/cl/6499075
2012-09-05 14:53:13 +10:00
Rob Pike
9dfc6f6427 go_spec.html: clarify rune and string literals
No changes to the meaning, just clearer language and more
examples, including illegal rune and string literals.
In particular, "character literal" and "character constant"
are now called "rune literal" and "rune constant" and the
word "character" always refers to the source text, not
program values.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6448137
2012-08-29 14:46:57 -07:00
Robert Griesemer
95a00cae2e go_spec: unary + and - are also defined for complex types
R=r, rsc, iant, ken, iant
CC=golang-dev
https://golang.org/cl/6450150
2012-08-17 11:36:21 -07:00
Robert Griesemer
f05a91e18b spec: clarify evaluation order
Fixes #3852.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6441102
2012-08-09 11:50:16 -07:00
Rémy Oudompheng
2b4cc6ccb5 spec: correct typo in string conversion examples.
R=golang-dev, dave, r
CC=golang-dev, remy
https://golang.org/cl/6378046
2012-07-11 20:26:51 +02:00
Matthew William Jibson
f83a47cbb9 doc: various "the the" and other typos
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6355076
2012-07-08 11:57:04 +10:00
Robert Griesemer
71de83b733 go spec: clean up section on selectors
- point out difference between selectors and qualified identifiers
- differentiate between illegal selectors and run-time panics
- use "indirect" as opposed to "dereference" consistently
- add extra links

Fixes #3779.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6326059
2012-06-28 12:22:24 -07:00
Robert Griesemer
809e06babc go spec: clean up use of QualifiedIdent production.
Fixes #3763.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6333066
2012-06-26 11:49:19 -07:00
Robert Griesemer
689931c5b0 spec: clarify receive operator
- receiving from a closed channel returns immediately
- in the ,ok form, the 2nd result is of type bool, not
  just boolean (gc and ggcgo agree).

Per dsymonds' suggestion.

R=r, rsc, ken, iant, dsymonds
CC=golang-dev
https://golang.org/cl/6333057
2012-06-25 11:28:24 -07:00
Robert Griesemer
787adb6eb3 go spec: clarify promotion rules for methods/fields of anonymous fields
Fixes #3635.

R=rsc, r, iant, kevlar, iant
CC=golang-dev
https://golang.org/cl/6217045
2012-06-04 14:24:10 -07:00
Robert Griesemer
2dde4f5d29 spec: clarify evaluation order of "i, x[i] = range ..."
Part of fix for issue 3464.

R=golang-dev, rsc, mirtchovski, iant, r
CC=golang-dev
https://golang.org/cl/6246045
2012-05-24 10:59:48 -07:00
Shenghou Ma
9bc8dd3985 doc/go_spec: fix a typo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5989065
2012-04-10 01:50:46 +08:00
Hong Ruiqi
8374e67876 doc/go_spec: fix typo
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5990043
2012-04-05 22:37:07 +10:00
Shenghou Ma
2195f1aa04 doc/go_spec: fix broken link
Part of issue 3424

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5955049
2012-03-30 14:04:03 +08:00
Jeremy Jackins
7e054266c9 doc: various typos, remove apostrophes from ordinals
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5845059
2012-03-19 08:26:36 +11:00
Rob Pike
883a96d950 spec: delete references to unsafe.Reflect,Typeof,Unreflect
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
2012-03-17 22:50:59 +11:00
Robert Griesemer
82fc28c0f5 go spec: fix inaccuracy in type identity definition
Pointed out by Steven Blenkinsop (steven099@gmail.com)
via golang-nuts.

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/5783087
2012-03-12 20:27:27 -07:00
Robert Griesemer
11d8b155ce go_spec: no known implementation differences anymore
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/5781048
2012-03-07 22:17:40 -08:00