[go-nuts] Re: Using generics to solve Optional argument problem for multiple methods

2022-07-28 Thread John
Thanks Henry and Harry. This helped expose me to some other options. The only thing about these is they don't particularly look user friendly (which I didn't ask for). I've streamlined my version (non-generic) out to this: https://github.com/johnsiilver/calloptions . The godoc has an explanatio

[go-nuts] Re: Using generics to solve Optional argument problem for multiple methods

2022-07-28 Thread Andrew Harris
There's a trivial conversion from any shared option to a flavored optionFunc[T]: type optionFunc[T any] func(*client) func reflavor[T any]( shared func(*client)) optionFunc[T] { return optionFunc[T](shared) } I'm not sure exactly where reflavoring shared -> optionFunc[T] would fit in best,

[go-nuts] lift - a package for generics and type lifting

2022-07-28 Thread Andrew Harris
Hi! Experimenting with Go generics since the 1.18 release, my best trick has been: type enum[T any] struct{} This resulting parametric type has lifted a type flavor, but can be boxed non-parametrically and still match any similarly flavored enum. Recently I tried pulling this idea into a `lift