Re:Maybe adding generics to Go is about syntax after all
by cyphar on Tuesday September 04, 2018 @01:05PM
(#17910663)
Well -- what if you have multiple implementations of an interface and you want users to be able to choose between them (or rather, you want them to be able to write functions around your interfaces)? I don't really like it much either, but it's a completely valid usecase for unexported methods. In fact I'm pretty sure this was an example from the language developers for why you can have unexported interface methods in Go.
Re:Maybe adding generics to Go is about syntax after all
by burntsushi on Tuesday September 04, 2018 @01:50PM
(#17911160)
> In fact I'm pretty sure this was an example from the language developers for why you can have unexported interface methods in Go.
Indeed. It's used in the standard library for describing Go's AST if I recall correctly.
What a horrible hack. Why bother with that? Either export your interface, your don't.