Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5)

Delta Between Two Patch Sets: doc/go_spec.html

Issue 6498138: code review 6498138: spec: clarify expression statements (Closed)
Left Patch Set: diff -r d27358d77d44 https://code.google.com/p/go Created 12 years, 6 months ago
Right Patch Set: diff -r 65c87ef9aae6 https://code.google.com/p/go Created 12 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 <!--{ 1 <!--{
2 "Title": "The Go Programming Language Specification", 2 "Title": "The Go Programming Language Specification",
3 » "Subtitle": "Version of September 17, 2012", 3 » "Subtitle": "Version of September 18, 2012",
4 "Path": "/ref/spec" 4 "Path": "/ref/spec"
5 }--> 5 }-->
6 6
7 <!-- 7 <!--
8 TODO 8 TODO
9 [ ] need language about function/method calls and parameter passing rules 9 [ ] need language about function/method calls and parameter passing rules
10 [ ] last paragraph of #Assignments (constant promotion) should be elsewhere 10 [ ] last paragraph of #Assignments (constant promotion) should be elsewhere
11 and mention assignment to empty interface. 11 and mention assignment to empty interface.
12 [ ] need to say something about "scope" of selectors? 12 [ ] need to say something about "scope" of selectors?
13 [ ] clarify what a field name is in struct declarations 13 [ ] clarify what a field name is in struct declarations
(...skipping 3777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3791 </pre> 3791 </pre>
3792 3792
3793 <pre> 3793 <pre>
3794 Error: log.Panic("error encountered") 3794 Error: log.Panic("error encountered")
3795 </pre> 3795 </pre>
3796 3796
3797 3797
3798 <h3 id="Expression_statements">Expression statements</h3> 3798 <h3 id="Expression_statements">Expression statements</h3>
3799 3799
3800 <p> 3800 <p>
3801 Function and method <a href="#Calls">calls</a> 3801 With the exception of specific built-in functions,
3802 (excluding calls of <a href="#Built-in_functions">built-in functions</a>), 3802 function and method <a href="#Calls">calls</a> and
3803 and <a href="#Receive_operator">receive operations</a> 3803 <a href="#Receive_operator">receive operations</a>
3804 can appear in statement context. Such statements may be parenthesized. 3804 can appear in statement context. Such statements may be parenthesized.
3805 </p> 3805 </p>
3806 3806
3807 <pre class="ebnf"> 3807 <pre class="ebnf">
3808 ExpressionStmt = Expression . 3808 ExpressionStmt = Expression .
3809 </pre>
3810
3811 <p>
3812 The following built-in functions are not permitted in statement context:
3813 </p>
3814
3815 <pre>
3816 append cap complex imag len make new real
3817 unsafe.Alignof unsafe.Offsetof unsafe.Sizeof
3809 </pre> 3818 </pre>
3810 3819
3811 <pre> 3820 <pre>
3812 h(x+y) 3821 h(x+y)
3813 f.Close() 3822 f.Close()
3814 &lt;-ch 3823 &lt;-ch
3815 (&lt;-ch) 3824 (&lt;-ch)
3816 len("foo") // illegal if len is the built-in function 3825 len("foo") // illegal if len is the built-in function
3817 </pre> 3826 </pre>
3818 3827
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
4807 4816
4808 <p> 4817 <p>
4809 The length and capacity of a <code>nil</code> slice, map, or channel are 0. 4818 The length and capacity of a <code>nil</code> slice, map, or channel are 0.
4810 </p> 4819 </p>
4811 4820
4812 <p> 4821 <p>
4813 The expression <code>len(s)</code> is <a href="#Constants">constant</a> if 4822 The expression <code>len(s)</code> is <a href="#Constants">constant</a> if
4814 <code>s</code> is a string constant. The expressions <code>len(s)</code> and 4823 <code>s</code> is a string constant. The expressions <code>len(s)</code> and
4815 <code>cap(s)</code> are constants if the type of <code>s</code> is an array 4824 <code>cap(s)</code> are constants if the type of <code>s</code> is an array
4816 or pointer to an array and the expression <code>s</code> does not contain 4825 or pointer to an array and the expression <code>s</code> does not contain
4817 function or method <a href="#Calls">calls</a> (excluding calls to built-in 4826 <a href="#Receive_operator">channel receives</a> or
4818 functions), or <a href="#Receive_operator">receive operations</a>; in this 4827 <a href="#Calls">function calls</a>; in this case <code>s</code> is not evaluate d.
4819 case <code>s</code> is not evaluated.
4820 Otherwise, invocations of <code>len</code> and <code>cap</code> are not 4828 Otherwise, invocations of <code>len</code> and <code>cap</code> are not
4821 constant and <code>s</code> is evaluated. 4829 constant and <code>s</code> is evaluated.
4822 </p> 4830 </p>
4823 4831
4824 4832
4825 <h3 id="Allocation">Allocation</h3> 4833 <h3 id="Allocation">Allocation</h3>
4826 4834
4827 <p> 4835 <p>
4828 The built-in function <code>new</code> takes a type <code>T</code> and 4836 The built-in function <code>new</code> takes a type <code>T</code> and
4829 returns a value of type <code>*T</code>. 4837 returns a value of type <code>*T</code>.
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
5489 <p> 5497 <p>
5490 Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code > can be converted into 5498 Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code > can be converted into
5491 a <code>Pointer</code> and vice versa. 5499 a <code>Pointer</code> and vice versa.
5492 </p> 5500 </p>
5493 <p> 5501 <p>
5494 The functions <code>Alignof</code> and <code>Sizeof</code> take an expression <c ode>x</code> 5502 The functions <code>Alignof</code> and <code>Sizeof</code> take an expression <c ode>x</code>
5495 of any type and return the alignment or size, respectively, of a hypothetical va riable <code>v</code> 5503 of any type and return the alignment or size, respectively, of a hypothetical va riable <code>v</code>
5496 as if <code>v</code> was declared via <code>var v = x</code>. 5504 as if <code>v</code> was declared via <code>var v = x</code>.
5497 </p> 5505 </p>
5498 <p> 5506 <p>
5499 The function <code>Offsetof</code> takes a selector (§<a href="#Selectors">Selec tors</a>) denoting a struct 5507 The function <code>Offsetof</code> takes a (possibly parenthesized) <a href="#Se lectors">selector</a>
5500 field of any type and returns the field offset in bytes relative to the 5508 denoting a struct field of any type and returns the field offset in bytes relati ve to the
5501 struct's address. 5509 struct's address.
5502 For a struct <code>s</code> with field <code>f</code>: 5510 For a struct <code>s</code> with field <code>f</code>:
5503 </p> 5511 </p>
5504 5512
5505 <pre> 5513 <pre>
5506 uintptr(unsafe.Pointer(&amp;s)) + unsafe.Offsetof(s.f) == uintptr(unsafe.Pointer (&amp;s.f)) 5514 uintptr(unsafe.Pointer(&amp;s)) + unsafe.Offsetof(s.f) == uintptr(unsafe.Pointer (&amp;s.f))
5507 </pre> 5515 </pre>
5508 5516
5509 <p> 5517 <p>
5510 Computer architectures may require memory addresses to be <i>aligned</i>; 5518 Computer architectures may require memory addresses to be <i>aligned</i>;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5552 </li> 5560 </li>
5553 5561
5554 <li>For a variable <code>x</code> of array type: <code>unsafe.Alignof(x)</code> is the same as 5562 <li>For a variable <code>x</code> of array type: <code>unsafe.Alignof(x)</code> is the same as
5555 <code>unsafe.Alignof(x[0])</code>, but at least 1. 5563 <code>unsafe.Alignof(x[0])</code>, but at least 1.
5556 </li> 5564 </li>
5557 </ol> 5565 </ol>
5558 5566
5559 <p> 5567 <p>
5560 A struct or array type has size zero if it contains no fields (or elements, resp ectively) that have a size greater than zero. Two distinct zero-size variables m ay have the same address in memory. 5568 A struct or array type has size zero if it contains no fields (or elements, resp ectively) that have a size greater than zero. Two distinct zero-size variables m ay have the same address in memory.
5561 </p> 5569 </p>
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b