Re: Decision Tables



On Jan 30, 12:11 am, Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
kwikius <a...@xxxxxxxxxxxxxxxxxxxxxxxxx> writes:

<snip most of the code, but it enables this:>





int main()
{
   D d1("John","Smith","England");
   D d2("John","Jones","England");

   typedef Dpred<&D::first_name> d_first_name;
   typedef Dpred<&D::last_name> d_last_name;
   typedef Dpred<&D::country> d_country;

   std::cout << (d_first_name(d1,d2) &&  d_last_name(d1,d2) &&
d_country(d1,d2)) << '\n';

   d_first_name first_name(d1,d2);
   d_last_name last_name(d1,d2);
   d_country country(d1,d2);

   std::cout << (first_name && (last_name || country)) << '\n';
   std::cout << (first_name && !last_name && country) << '\n';
}

I may be missing your point, but I *think* the OP wanted a way to
"store" (or at least represent) compound predicates which can the be
evaluated against an unknown data item.  I don't think your example
shows this.

Maybe :-)

I took your pseudocode:

"
complex_match[] = { match_contry, match_not, match_first_name,
match_or, NULL };
"
which is a static expression, and with the stack machine the language
is something like Forth ?

and I figured that it wasnt very easy to read the expression syntax
and the solution seemed a prime candidate for C++ operator
overloading. Again the expression is statically evaluated.

Once happy with the syntax, you could write a script which mirrors
the C++ syntax:

"first_name && (last_name || country)"

which is IMO easier to comprehend than:

"match_country match_not, match_first_name,
match_or"


Anyway I would guess the simplest solution would be a database and
SQL.

regards
Andy Little






.



Relevant Pages