Re: [rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Barry Kaplan

Ok, I found http://n3.nabble.com/Strange-MVEL-error-td62055.html#a62055 which
indicates that expressions are disabled in mvel RHS. I understand good
intentions, but I **need** this expression for this particular situation.
Anybody know some what to turn this back on?

Also, when I try wrap the RHS in a function, that also fails. I'm guessing
because I declare dialect mvel for the entire file. If this is why
function fails to compile with an if-statement, this must be a bug.
-- 
View this message in context: 
http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67472.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread CK
I would assume that you're trying to test out rule writing and see  
what works and what doesn't.   I don't believe you can use if  
statements in the RHS.

Normally, anytime you want to use if statements inside the RHS, it's  
a sure sign that you should move it to the LHS and create separate  
rules.

You can actually make your rule even simpler:

rule test
dialect mvel
when
   //empty LHS automatically implies true
then
   System.out.pritln(***)
end

Cheers,
Chris

On Dec 3, 2009, at 11:43 AM, Barry Kaplan wrote:


 The following rule:

 rule test dialect mvel
 when
eval(true)
 then
if (true) {
System.out.println(***)
}
 end

 Fails with:

 java.lang.RuntimeException: Unable to build expression for  
 'consequence':
 was expecting type: java.lang.Object; but found type: void 'if  
 (true) {
System.out.println(***)
}
true
 ' : [Rule name='test']

 I can't for the live of me figure out what mvel is bitching about.

 Note that the following does compile:

 rule test dialect mvel
 when
eval(true)
 then
 //if (true) {
System.out.println(***)
 //}
 end
 -- 
 View this message in context: 
 http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67458.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Barry Kaplan

The following rule:

rule test dialect mvel
when
eval(true)
then
if (true) {
System.out.println(***)
}
end

Fails with:

java.lang.RuntimeException: Unable to build expression for 'consequence':
was expecting type: java.lang.Object; but found type: void 'if (true) {
System.out.println(***)
}
true
' : [Rule name='test']

I can't for the live of me figure out what mvel is bitching about.

Note that the following does compile:

rule test dialect mvel
when
eval(true)
then
//if (true) {
System.out.println(***)
//}
end
-- 
View this message in context: 
http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67458.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Barry Kaplan


Greg Barton wrote:
 
 You can use them in the RHS, but just with java dialect. 
 

This is inconsistent. If they can be used in java, then they should not be
disabled for mvel. 



-- 
View this message in context: 
http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67488.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Greg Barton
You can use them in the RHS, but just with java dialect. The RHS code should 
then be passed through with no modification.

And there are occasional reasons why you would want to test conditions in the 
RHS (optimization, mostly) but should be avoided most of the time.

--- On Thu, 12/3/09, CK chris...@gmail.com wrote:

 From: CK chris...@gmail.com
 Subject: Re: [rules-users] Trivial rule with condition in RHS won't compile, 
 help please
 To: Rules Users List rules-users@lists.jboss.org
 Date: Thursday, December 3, 2009, 1:49 PM
 I would assume that you're trying to
 test out rule writing and see  
 what works and what doesn't.   I don't
 believe you can use if  
 statements in the RHS.
 
 Normally, anytime you want to use if statements inside
 the RHS, it's  
 a sure sign that you should move it to the LHS and create
 separate  
 rules.
 
 You can actually make your rule even simpler:
 
 rule test
 dialect mvel
 when
    //empty LHS automatically implies true
 then
    System.out.pritln(***)
 end
 
 Cheers,
 Chris
 
 On Dec 3, 2009, at 11:43 AM, Barry Kaplan wrote:
 
 
  The following rule:
 
  rule test dialect mvel
  when
     eval(true)
  then
     if (true) {
         System.out.println(***)
     }
  end
 
  Fails with:
 
  java.lang.RuntimeException: Unable to build expression
 for  
  'consequence':
  was expecting type: java.lang.Object; but found type:
 void '    if  
  (true) {
         System.out.println(***)
     }
     true
  ' : [Rule name='test']
 
  I can't for the live of me figure out what mvel is
 bitching about.
 
  Note that the following does compile:
 
  rule test dialect mvel
  when
     eval(true)
  then
  //    if (true) {
         System.out.println(***)
  //    }
  end
  -- 
  View this message in context: 
  http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67458.html
  Sent from the Drools - User mailing list archive at
 Nabble.com.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 


  

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Greg Barton
Well, technically you choose a different dialect because you want different 
functionality, so consistency isn't a requirement.  I do agree that the 
difference is not intuitive.  I'm not sure why they're disabled in mvel.  Dev 
d00ds?  If the reason is just to enforce the you shouldn't have conditions in 
the RHS pattern then I don't think that's sufficient.

--- On Thu, 12/3/09, Barry Kaplan grou...@memelet.com wrote:

 From: Barry Kaplan grou...@memelet.com
 Subject: Re: [rules-users] Trivial rule with condition in RHS won't compile, 
 help please
 To: rules-users@lists.jboss.org
 Date: Thursday, December 3, 2009, 2:07 PM
 
 
 Greg Barton wrote:
  
  You can use them in the RHS, but just with java
 dialect. 
  
 
 This is inconsistent. If they can be used in java, then
 they should not be
 disabled for mvel. 
 
 
 
 -- 
 View this message in context: 
 http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67488.html
 Sent from the Drools - User mailing list archive at
 Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 


  
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users