The "hole" the DRL 3.0 syntax was dug out of appears to be the same as other
leading rules based implementations such as JRules-IRL, Jess, CLIPS etc.

I for one applaud the familiar, convenient and relatively standard 3.0
syntax.

-Mitch

-----Original Message-----
From: Hamu, Dave [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 14, 2006 9:26 AM
To: [email protected]
Subject: RE: [drools-user] The DRL notation vs. jbossrules Rule Language - ?

Dmitry,

I have to concur with you, the syntax that has been implemented for the
Java Semantics is really whacky!  I'm not sure what hole this semantics
was dug out of, but it kinda sucks. 

Better would be:

(objA : ClassA.getStringAttr()) == "xyz"

I understand what is being done here is to take some of the effort out
of the process so that the developer does not need to write a rule to
populate scalar attributes, but at what cost???

Why not provide a declaration section above the when/then clauses so
that the developer could write the rule as:

rule "Better First Rule"
declare
        objA = ClassA.getStringAttr()
        objB = ClassB.getIntAttr()
when 
        (objA == "xyz")
        (objB > 50)
then
        // do some java code
end

Even then, there are some issues because of the fact that Java is a
typed language.  Who's job is it to ensure that the comparisons and the
"do some java code" are type-safe?  Wouldn't it be better if we stick
with type declarations as they existed in Drools 2.0?  I have to admit
that while there are some cool things going on in Drools 3.0, some of
the decisions that have been made wrt Java semantics are puzzling.  The
beauty of Drools for a Java developer was the purity and the seamless
integration of the Drools Java Semantics and JAVA!  Why sacrifice that
purity???

Just MHO.

- Dave


-----Original Message-----
From: Dmitry Goldenberg [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 14, 2006 9:01 AM
To: [email protected]
Subject: RE: [drools-user] The DRL notation vs. jbossrules Rule Language
- ?

rule "First Rule"
when
    ClassA( stringAttr == "xyz" )
    ClassB( intAttr > 50 )
then
    // do some java code
end
 
In this example, where is the call made to the getStringAttr() and
getIntAttr() methods on instances of ClassA and ClassB ??
 
rule "First Rule"
when
    objA : ClassA( stringAttr == "xyz" )
    objB : ClassB( intAttr > 50 )
then
    // do some java code
   System.out.println(objA);
   System.out.println(objB);
end
 
Here, are objA and objB Boolean ?
 

________________________________

From: Edson Tirelli [mailto:[EMAIL PROTECTED]
Sent: Thu 4/13/2006 3:47 PM
To: [email protected]
Subject: Re: [drools-user] The DRL notation vs. jbossrules Rule Language
- ?



    All,

    Find in the following link, the documentation that is being built
for drools 3.

http://labs.jboss.com/portal/jbossrules/docs

   On a quick explanation, the new syntax would be:

------------
rule "name"
    ATTRIBUTES
    when
        LHS
    then
        RHS
end
------------

ATTRIBUTES: those are rule attributes like salience, duration, etc, in a
similar way Drools 2.x uses.

LHS: this is the left hand side of the rule. This is the previous
"parameter" + "condition" statements. (see bellow)

RHS: this is the right hand side of the rule. This is the consequence,
the same way in drools 2.

   I think the simple way to explain LHS is to make a conversion
example:


<rule name="First Rule">

<parameter identifier="objA">
  <class>ClassA</class>
</parameter>

<parameter identifier="objB">
  <class>ClassB</class>
</parameter>

<java:condition> objA.getStringAttr().equals("xyz") </java:condition>
<java:condition> objB.getIntAttr() &gt 50 </java:condition>

<java:consequence>
   // some java code
</java:consequence>

</rule>

   The above rule when converted to Drools 3 would became:

rule "First Rule"
when
    ClassA( stringAttr == "xyz" )
    ClassB( intAttr > 50 )
then
    // do some java code
end

   If you need a reference to the actual object matched in each "column"
(more or less what Drools 2 call parameter), you can bind it in the
following way:

rule "First Rule"
when
    objA : ClassA( stringAttr == "xyz" )
    objB : ClassB( intAttr > 50 )
then
    // do some java code
   System.out.println(objA);
   System.out.println(objB);
end

   In the documentation you will find syntax diagrams that can help you
understand all possible syntaxes and all the new operators/features
drools 3 has.

   []s
   Edson


Ronald van Kuijk wrote:

>AINAE, but it could be as simple as 'replacing' condition with when and

>consequence with then, but I'll let the experts tell me.
>
>Ronald
>
>2006/4/13, Dmitry Goldenberg <[EMAIL PROTECTED]>:
> 
>
>>I don't understand the relationship between the XML-based DRL notation

>>and this new lingo with "when" / "then".
>>
>>With the DRL notation, my understanding is that you write an XML 
>>structure like the one I'm including below.  How does this change with

>>the when/then notation?  Thanks.
>>
>>
>><?xml version="1.0"?>
>>
>><rule-set name="SamplePolicyRuleSet"
>>
>>  xmlns="http://drools.org/rules";
>>
>>  xmlns:java="http://drools.org/semantics/java";
>>
>>  xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
>>
>>  xs:schemaLocation="http://drools.org/rules rules.xsd 
>>http://drools.org/semantics/java java.xsd">
>>
>>
>>
>>  <!-- Imports -->
>>
>>  <java:import>java.lang.Object</java:import>
>>
>>  <java:import>java.lang.String</java:import>
>>
>>  <!-- Utility functions -->
>>
>>  <java:functions>
>>
>>    public boolean 
>> f1(com.weblayers.platform.rule.PolicyExecContextcontext)
>>
>>    {
>>
>>        return ...;
>>
>>    }
>>
>>    public boolean 
>> f2(com.weblayers.platform.rule.PolicyExecContextcontext)
>>
>>    {
>>
>>        return ...;
>>
>>    }
>>
>>  </java:functions>
>>
>>
>>
>>  <!-First Rule: IF (P1 AND P2) THEN RETURN OK -->
>>
>>  <rule name="First Rule">
>>
>>    <!-- Rule parameters -->
>>
>>    <parameter identifier="context">
>>
>>      <class>MyContext</class>
>>
>>    </parameter>
>>
>>
>>
>>    <!-- Rule Conditions -->
>>
>>    <java:condition>
>>
>>      f1() && f2()
>>
>>    </java:condition>
>>
>>
>>
>>    <!-- Rule Consequences -->
>>
>>    <java:consequence>
>>
>>       context.setReturn(Constants.OK);
>>
>>    </java:consequence>
>>
>>  </rule>
>>
>>
>>
>>  <!-Second Rule: IF (!(P1 AND P2)) THEN RETURN FAILURE -->
>>
>>  <rule name="Second Rule">
>>
>>    <!-- Rule parameters -->
>>
>>    <parameter identifier="context">
>>
>>      <class>MyContext</class>
>>
>>    </parameter>
>>
>>
>>
>>    <!-- Rule Conditions -->
>>
>>    <java:condition>
>>
>>      !(f1() && f2())
>>
>>    </java:condition>
>>
>>
>>
>>    <!-- Rule Consequences -->
>>
>>    <java:consequence>
>>
>>       context.setVerdict(Constants.FAIL);
>>
>>    </java:consequence>
>>
>>  </rule>
>>
>>
>>
>></rule-set>
>>
>>
>>
>>
>>
>>   
>>
>
> 
>


--
  ---
  Edson Tirelli
  Auster Solutions do Brasil
  @ www.auster.com.br
  +55 11 5096-2277 / +55 11 9218-4151



Reply via email to