Skip to content
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

Remove PartSpec and use reflection #10

Closed
db47h opened this issue Jun 13, 2018 · 3 comments
Closed

Remove PartSpec and use reflection #10

db47h opened this issue Jun 13, 2018 · 3 comments
Labels
API API change, possibly breaking enhancement misc. enhancements

Comments

@db47h
Copy link
Owner

db47h commented Jun 13, 2018

For custom components, what if we did something like this:

type Mux8 struct {
    In  [8]int `hw:in`
    Sel int    `hw:in`
    Out [8]int `hw:out`
}

func (m *Mux8) Update(c *Circuit) {
    // ...
}

// Along with a Component interface
type Component interface {
    Update(c *Circuit)
}

And use reflect to get the specs of a part. Chip.mount could then instantiate parts as needed and init their input/outputs.

@db47h db47h added enhancement misc. enhancements API API change, possibly breaking labels Jun 13, 2018
@db47h
Copy link
Owner Author

db47h commented Jun 13, 2018

@db47h
Copy link
Owner Author

db47h commented Jun 14, 2018

The prototype works with PartSpec. Plus it's les flexible than PartSpec:

Cons:

  • Flexibility: How to implement the simple gates without a lot of boiler plate code?

Pros:

  • No need to implement PartSpec.Mount
  • Cleaner

@db47h
Copy link
Owner Author

db47h commented Jun 14, 2018

Merged 34622ac

@db47h db47h closed this as completed Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API change, possibly breaking enhancement misc. enhancements
Projects
None yet
Development

No branches or pull requests

1 participant