This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Support more than 3 types #2
Comments
Sure, I'd be happy to accept a PR for this. |
whatever happened with this idea? |
I'd still like to do this at some point, but it hasn't been an issue for me thus far. The command-line should probably take key/value arguments to support this. Something like:
If the key ( |
The 'key=value' syntax seems good to me. :) |
I'd like to see something like this (just to have explicit examples, I think I'm in agreement with schancel): type Value gengen.Generic
type SortedSet interface {
Insert(Value) bool
Remove(value) bool
Pop() Value
}
func NewSortedSet(comparator func(a, b Value) int) SortedSet { ... } // go:generate gengen github.com/example/SortedSet Value=int
// would result in the following code:
type SortedSet interface {
Insert(int) bool
Remove(int) bool
Pop() int
}
func NewSortedSet(comparator func(a, b int) int) SortedSet { ... } // go:generate gengen github.com/example/SortedSet Value=string
// would result in the following code:
type SortedSet interface {
Insert(string) bool
Remove(string) bool
Pop() string
}
func NewSortedSet(comparator func(a, b string) int) SortedSet { ... } Multiple Generic Types example: type Key gengen.Generic
type Value gengen.Generic
type Map interface {
Insert(Key, Value) bool
Delete(Key) bool
} // go:generate gengen github.com/example/Map Key=int Value=string
// would result in the following code:
type Map interface {
Insert(int, string) bool
Delete(int) bool
} This would support arbitrary number of polymorphic parameters, and be straight forward to use, can still leverage golang's ast package, and would still be valid go code. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Should support more than 3 types. They could be defined in the go generic source via:
type Param generic.Type;
The gengen.go could scan the file for these top-level decls and add them to generic types.
If you'd accept a PR for this, I could do it probably.
The text was updated successfully, but these errors were encountered: