2 ms·
The options for the thing being constructed are all separate types from the thing being constructed; the options aren’t a facet of the definition of the type th
by zemo 3y ago
The options for the thing being constructed are all separate types from the thing being constructed; the options aren’t a facet of the definition of the type they mutate.
- kubanczyk 3y agoI'm saying: - main constructor is easily available from the main type's docs, - option type is easily available from the main constructor's docs, - all option funcs are easily available from the option type's docs (because in fact these option funcs are constructors for the option type). Excerpt from grpc godoc index: type Server func NewServer(opt ...ServerOption) *Server ... ... type ServerOption func ChainStreamInterceptor(interceptors ...StreamServerInterceptor) ServerOption func ChainUnaryInterceptor(interceptors ...UnaryServerInterceptor) ServerOption func ConnectionTimeout(d time.Duration) ServerOption func Creds(c credentials.TransportCredentials) ServerOption etc... One more hop compared to a flat argument list, that's true. But if you only commonly use maybe 0-5 arguments out of 30-50 available, it does not look like a bad deal.
- zemo 3y agoI’m not confused about what it is, I just don’t like it. It’s a lot of ceremony for very little gain.