Thanks Matt for correcting this.
Actually Drools processes DSL a similar way it process rules, doesn't it ?
I couldn't find any documentation about Drools 5 (I downloaded it but
it looks like it it the same as 4.0.7). Where could I find it ?
2008/12/16 Matt Geis <mgeis(a)yahoo.com>:
Minor correction:
>>Drools stops on the first DSL sentence it can map to.
[false]
>>If you want it to work, you have to be careful about the order you write sentences
in your DSL : write them from the most restricitive to the less.
[depends on what you want to accomplish]
Drools actually does not stop until it hits the end of the DSL entry list. For each
domain specific block of text it has to turn back into DRL, it tries to match/replace on
every DSL mapping entry. So, if you DRL file has 10 lines of conditions (the
"when" block) spread across n rules, 6 lines of consequences (the
"then" block), and your DSL file has 10 lines, 4 for "any", 3
"when", and 3 "then", you will have 70+24 = 94 different attempts to
match/replace. The engine will not stop at the first match, as subsequent matches may
apply.
Some people take this behavior into account when building their DSLs.
In short, you aren't really writing a simple name/value pair list. You're
writing a transformation engine, through which any entry can be transformed at multiple
points along the way. Raw entry A may not match DSL mapping entry 5, but after it matches
entry 3, the replacement then matches entry 5.
Example:
start with input A
try to match a to entry 1, fail
try to match a to entry 2, fail
try to match a to entry 3, success, transform to B.
try to match b to entry 4, fail
try to match b to entry 5, success, transform to c.
Return c.
Hope that helps,
Matt
ps. If you start getting into this and find the expressiveness of the language you want
to build a bit restrictive in Drools 4, give Drools 5 a test drive. You'll find that
the implementation of DSLs in Drools 5 is a more complete implementation of the original
design. Drools 5 DSL changes were a result of people pushing Drools 4 to and finally a
bit past what it was capable of, when trying to realize exactly the kind of behavior
you've been discussing.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Seules 2 choses sont infinies : l'univers et la bêtise humaine ; et
encore pour l'univers, je ne suis pas sûr … (Einstein)