New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match on more than just interface{} #13

Open
jamesgarfield opened this Issue Apr 15, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@jamesgarfield
Contributor

jamesgarfield commented Apr 15, 2015

Provide the ability for metacode to specify an interface that must satisfied (beyond interface{}) to have a matching type. This will work in a somewhat analogous way to how Concepts are supposed to work in C++

E.g. Allow for code along the lines of https://gist.github.com/egonelbre/d6787bfff0684cddbd10 to be generated

package set
type Elem interface {
    Hash() int64
    Equals(e Elem) bool
}

type _Set struct {
    buckets map[int64][]Elem
    size int
    ...
}

func New_Set() *Set { return &Set{make(map[int64][]Elem)} }
func (s *Set) Insert(v Elem) { ... }
func (s *Set) Remove(v Elem) { ... }
func (s *Set) Union(s *Set) *Set { ... }
func (s *Set) Count() int { ... }
func (s *Set) Contains(v Elem) bool { ... }
func (s *Set) ForEach(fn func(Elem)) { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment