News for hackers. Stuff that matters.
Re:Decorators in Go using embedded structs by weberc2 on Wednesday October 23, 2019 @02:15PM (#21337271)
This might be a bad practice, but I don't feel very bad if you subvert the type system like this and it bites you. If `io.ReaderTo` is important, it should be a bonafide first-class method, not something that's determined and dispatched to via reflection.
Re:Decorators in Go using embedded structs by inlined on Wednesday October 23, 2019 @03:58PM (#21338279)
This is the way that “optional” methods work in Go. For example, go decided not to rebuild the entire HTTP library to support web sockets. Instead, supported servers will pass an http.Request that also implements http.Hijacker for letting a request stay alive after the Handler closure
Re:Decorators in Go using embedded structs by weberc2 on Wednesday October 23, 2019 @05:27PM (#21339181)
I get it, but I disagree with subverting the type system. The type system is there to promote safety and maintainability; you shouldn't subvert it even if "you" are the std lib.