blob: eabca8e7c5c03dd8adee0f02965de5d00ab8f374 [file] [log] [blame] [view]
Andrew Gerrand5bc444d2014-12-10 11:35:11 +11001# Introduction
2
3This wiki entry will try to document the rationales behind some important language
4decisions besides what's included in the Go FAQ and Effective Go.
5
6# Language Features
7### Why method receiver's base type cannot be pointer or interface?
8Reference: https://groups.google.com/forum/#!topic/golang-nuts/aqTwXHaSC_Y
9
10Go doesn't allow receiver's base type to be pointer to avoid possible ambiguity.
11Suppose you have:
12```
13type T blah
14type P *T
15
16func (t *T) String() string { ... }
17func (p P) String() string { ... }
18
19var p P
20```
21
22Then the meaning of the expression ` (*p).String() ` is ambiguous, because it can refer to
23both ` (*T).String ` and ` P.String `.
24
25Go doesn't allow receiver's base type to be interfaces, because interfaces already have methods. (TODO)
26
27# Memory Model
28
29# Standard Library