-
Notifications
You must be signed in to change notification settings - Fork 560
Closed
Milestone
Description
Proposal
In Go, a recv *T pointer can be automatically converted to *Base. For example:
type Base struct {
...
}
func (p *Base) F() { ... }
type T struct {
Base
}A function call like p.F() is essentially equivalent to a call like (*Base).F(&p.Base), where &p.Base automatically converts the p *T into a *Base pointer.
We want the parameter behaviour in XGo to be consistent with the receiver pointer behaviour. That is, even if F is not a method but a function, this should still work:
func F(p *Base) { ... }For a p *T, when we call F(p), no type error will be raised. Instead, it will be automatically converted to a function call like F(&p.Base).