Skip to content

Replace interface with concrete type#4

Open
duckbrain wants to merge 1 commit intoetnz:masterfrom
duckbrain:remove-interface
Open

Replace interface with concrete type#4
duckbrain wants to merge 1 commit intoetnz:masterfrom
duckbrain:remove-interface

Conversation

@duckbrain
Copy link

Obviously, this is a breaking change. In many applications, it will work with few changes. If compatibility is desired, it can be achieved at the expense of API clarity. Perhaps, it's a candidate for boole.

This exposes the underlying types of expression and minterm as Expr (replacing the interface) and Term.

This provides a machine readable way to see the state of the expression, enabling tools like the simplifier to be utilized as a library.

@duckbrain duckbrain mentioned this pull request Aug 31, 2022
Copy link
Owner

@etnz etnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR,

small changes and a curiosity question, other than that, it LGTM so I will very likely approve it after those changes

func TestLit(t *testing.T) {
if !Lit(true).Is(true) {
if !Lit(true).isLiteral(true) {
t.Error("Lit(true).Is(true) must be true")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to adjust the error message

}
if !Lit(false).Is(false) {
if !Lit(false).isLiteral(false) {
t.Error("Lit(false).Is(false) must be true")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

//Is return true if this expression is equals to val
func (x expression) Is(val bool) bool {
// Is return true if this expression is equals to val
func (x Expr) isLiteral(val bool) bool {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this renaming?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants