LEFT | RIGHT |
1 <!-- title The Go Programming Language Specification --> | 1 <!-- title The Go Programming Language Specification --> |
2 <!-- subtitle Version of March 25, 2010 --> | 2 <!-- subtitle Version of March 25, 2010 --> |
3 | 3 |
4 <!-- | 4 <!-- |
5 Todo | 5 Todo |
6 [ ] clarify: two equal lowercase identifiers from different packages denote diff
erent objects | 6 [ ] clarify: two equal lowercase identifiers from different packages denote diff
erent objects |
7 [ ] need language about function/method calls and parameter passing rules | 7 [ ] need language about function/method calls and parameter passing rules |
8 [ ] last paragraph of #Assignments (constant promotion) should be elsewhere | 8 [ ] last paragraph of #Assignments (constant promotion) should be elsewhere |
9 and mention assignment to empty interface. | 9 and mention assignment to empty interface. |
10 [ ] need to say something about "scope" of selectors? | 10 [ ] need to say something about "scope" of selectors? |
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 type Cipher interface { | 1730 type Cipher interface { |
1731 BlockSize() int | 1731 BlockSize() int |
1732 Encrypt(src, dst []byte) | 1732 Encrypt(src, dst []byte) |
1733 Decrypt(src, dst []byte) | 1733 Decrypt(src, dst []byte) |
1734 } | 1734 } |
1735 </pre> | 1735 </pre> |
1736 | 1736 |
1737 <p> | 1737 <p> |
1738 The declared type does not inherit any <a href="#Method_declarations">methods</a
> | 1738 The declared type does not inherit any <a href="#Method_declarations">methods</a
> |
1739 bound to the existing type, but the <a href="#Types">method set</a> | 1739 bound to the existing type, but the <a href="#Types">method set</a> |
1740 of elements of a composite type is not changed: | 1740 of an interface type or of elements of a composite type remains unchanged: |
1741 </p> | 1741 </p> |
1742 | 1742 |
1743 <pre> | 1743 <pre> |
1744 // A Mutex is a data type with two methods Lock and Unlock. | 1744 // A Mutex is a data type with two methods Lock and Unlock. |
1745 type Mutex struct { /* Mutex fields */ } | 1745 type Mutex struct { /* Mutex fields */ } |
1746 func (m *Mutex) Lock() { /* Lock implementation */ } | 1746 func (m *Mutex) Lock() { /* Lock implementation */ } |
1747 func (m *Mutex) Unlock() { /* Unlock implementation */ } | 1747 func (m *Mutex) Unlock() { /* Unlock implementation */ } |
1748 | 1748 |
1749 // NewMutex has the same composition as Mutex but its method set is empty. | 1749 // NewMutex has the same composition as Mutex but its method set is empty. |
1750 type NewMutex Mutex | 1750 type NewMutex Mutex |
1751 | 1751 |
1752 // PrintableMutex's method set contains the methods | 1752 // PrintableMutex's method set contains the methods |
1753 // Lock and Unlock bound to its anonymous field Mutex. | 1753 // Lock and Unlock bound to its anonymous field Mutex. |
1754 type PrintableMutex struct { | 1754 type PrintableMutex struct { |
1755 Mutex | 1755 Mutex |
1756 } | 1756 } |
| 1757 |
| 1758 // MyCipher is an interface type that has the same method set as Cipher. |
| 1759 type MyCipher Cipher |
1757 </pre> | 1760 </pre> |
1758 | 1761 |
1759 <p> | 1762 <p> |
1760 A type declaration may be used to define a different boolean, numeric, or string | 1763 A type declaration may be used to define a different boolean, numeric, or string |
1761 type and attach methods to it: | 1764 type and attach methods to it: |
1762 </p> | 1765 </p> |
1763 | 1766 |
1764 <pre> | 1767 <pre> |
1765 type TimeZone int | 1768 type TimeZone int |
1766 | 1769 |
(...skipping 3340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5107 <h2 id="Implementation_differences"><span class="alert">Implementation differenc
es - TODO</span></h2> | 5110 <h2 id="Implementation_differences"><span class="alert">Implementation differenc
es - TODO</span></h2> |
5108 <ul> | 5111 <ul> |
5109 <li><span class="alert">Implementation does not honor the restriction on
goto statements and targets (no intervening declarations).</span></li> | 5112 <li><span class="alert">Implementation does not honor the restriction on
goto statements and targets (no intervening declarations).</span></li> |
5110 <li><span class="alert">Method expressions are partially implemented.</s
pan></li> | 5113 <li><span class="alert">Method expressions are partially implemented.</s
pan></li> |
5111 <li><span class="alert">Gccgo allows only one init() function per source
file.</span></li> | 5114 <li><span class="alert">Gccgo allows only one init() function per source
file.</span></li> |
5112 <li><span class="alert">Deferred functions cannot access the surrounding
function's result parameters.</span></li> | 5115 <li><span class="alert">Deferred functions cannot access the surrounding
function's result parameters.</span></li> |
5113 <li><span class="alert">Function results are not addressable in gccgo.</
span></li> | 5116 <li><span class="alert">Function results are not addressable in gccgo.</
span></li> |
5114 <li><span class="alert">Recover is not implemented.</span></li> | 5117 <li><span class="alert">Recover is not implemented.</span></li> |
5115 <li><span class="alert">The implemented version of panic differs from it
s specification.</span></li> | 5118 <li><span class="alert">The implemented version of panic differs from it
s specification.</span></li> |
5116 </ul> | 5119 </ul> |
LEFT | RIGHT |