Skip to content

Simplify logic system #5

@trans

Description

@trans

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions