There is currently no way to say "all applicable methods without type parameters"
Opened this issue · 3 comments
Currently if I put
// +gen slice
type Example struct {}
gen doesn't put any methods in the file. It would be helpful if gen would generate all methods compatible with the element type. That is, except the ones that take type parameters since there's no way to know in advance what they should be.
It would also be useful to allow something like this
// +gen slice:"*"
type Example struct {}
that means the same thing as above: all applicable non-parametrized methods. The difference would be that this could be combined with a list of methods that take type parameters. For example:
// +gen slice:"*,GroupBy[int]"
type Example struct {}
This means to generate all the applicable methods without type parameters, plus GroupBy[int].
What do you think?
Any comment on this? Are you still actively maintaining this project?
Hi @ijt sorry for the delayed response. This is nice work. I am not crazy about those sort of semantics – I much prefer explicit choices. Optimizing for clarity and reproducibility.
Earlier versions of gen did something like this, but then I had to add syntax for “everything except” and, yadda yadda.
I don’t disagree that the verbosity feels a bit much if one wants “everything the type will support”.
These semantics could be pushed to the specific typewriter. I might recommend that – make your own fork of slice
and support the defaults there.
Hi Matt,
Thanks, I'm glad you like it.
As far as adding the functionality directly to the slice typewriter, that's
what I tried first but I figured it made more sense to just solve the
problem once for all typewriters. I take the point though: if I want this
functionality I'll have to keep my own fork.
Thanks for making Gen available!
Issac
On Mon, Mar 7, 2016 at 6:13 PM Matt Sherman notifications@github.com
wrote:
Hi @ijt https://github.com/ijt sorry for the delayed response. This is
nice work. I am not crazy about those sort of semantics – I much prefer
explicit choices. Optimizing for clarity and reproducibility.Earlier versions of gen did something like this, but then I had to add
syntax for “everything except” and, yadda yadda.I don’t disagree that the verbosity feels a bit much if one wants
“everything the type will support”.These semantics could be pushed to the specific typewriter. I might
recommend that – make your own fork of slice and support the defaults
there.—
Reply to this email directly or view it on GitHub
#14 (comment)
.