▲ | Default Methods in Go(mcyoung.xyz) | |||||||
27 points by ingve 2 days ago | 7 comments | ||||||||
▲ | arp242 2 days ago | parent | next [-] | |||||||
The thing with default methods is that while the code may not "break" in the sense of "will not compile", it may very well break in the sense of "issues runtime panic", or even worse: "does the wrong thing". I do agree all of this can be quite painful, but I'm not so sure that default methods are the right solution. | ||||||||
▲ | dfawcus 2 days ago | parent | prev | next [-] | |||||||
> and there is no canonical way to document that A satisfies B Surely that is wrong:
Then we get:
| ||||||||
▲ | dfawcus 2 days ago | parent | prev | next [-] | |||||||
Also doesn't this disprove his default methods claim, or have I misunderstood?
| ||||||||
▲ | chabad360 2 days ago | parent | prev | next [-] | |||||||
I think the one really useful suggestion here is at the end of the article. Having some way for the compiler to know that a struct satisfies a particular interface, and thereby create a fast path that sidesteps reflection would be marked performance improvement (and avoid the need for caching). TBH, anything that can make interface casting faster/more efficient in go would be a welcome improvement. | ||||||||
▲ | mrjavid 2 days ago | parent | prev | next [-] | |||||||
[dead] | ||||||||
▲ | mama_mia9 2 days ago | parent | prev [-] | |||||||
[flagged] | ||||||||
|