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

Simplify logic system #5

Open
trans opened this issue Mar 1, 2015 · 0 comments
Open

Simplify logic system #5

trans opened this issue Mar 1, 2015 · 0 comments

Comments

@trans
Copy link
Member

trans commented Mar 1, 2015

It might be better to simplify things by removing the set-logic, and just rely on Boolean logic. That's a hard choice to make b/c the set-logic system was the essence of the "ah ha" moment that led to this project, and in-itself it is very cool and makes a hell of a lot of sense. The problem is, as it turns out, the degree of flexibility it provide is almost never needed.

For example, lets say we have two facts (or states, for older versions). We can write it either of two ways. Like this:

  fact :need_docs? do
    ...
  end

  fact :has_manpages? do
    ...
  end

  rule need_docs? & has_manpages? do
    ...
  end

Or like this:

  def need_docs? do
    ...
  end

  def has_manpages? do
    ...
  end

  rule fact(:need_docs?) & fact(:has_manpages?) do
    ...
  end

But we really don't need to go to all that trouble because we could just define a separate fact that combines the other two in it's definition. Like so:

  def need_docs?
    ...
  end

  def has_manpages?
    ...
  end

  def run_ronn?
    needs_docs? && has_manpages?
  end

  rule :run_ronn? => :run_ronn 

Notice there is no need for the fact method at all. Moreover we can extend the rule method to at least handle simple AND conjunctions, like this:

  rule :needs_docs?, :has_manpages? => :run_ronn

We could still keep the set-logic system under the hood. It wouldn't hurt anything to have and it may still be of some use in combining file-facts. If in the end, that too proves to be unnecessary then we can remove it altogether.

@trans trans changed the title Simply logic system Simplify logic system Mar 1, 2015
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

No branches or pull requests

1 participant