Yuri,
We support -> for backward compatibility and I confess I haven't seen this error before. I guess it may be complaining about the variable binding:
$age : age -> (Math.abs($age -
c1.age) < 10),
Anyway, if you can please open a JIRA for that.
An yes, we prefer to not use -> anymore, so if you are able to change this during your upgrade, then it is better to simply use the "eval" keyword instead of the ->. Example:
c2:Child( eval(Math.abs(age - c1.age) < 10), ...)
Note that if that is the only place where you use the "age" field, the binding is automatically created for you. You don't need to do it explicitly anymore. If you need the binding for other purposes, you can do a regular binding:
c2:Child( $age : age, eval(Math.abs($age - c1.age) < 10), ...)
Regarding your second questions, the answer is yes. We now support totally nestable && and || as constraints and restriction connectors. So:
p2: Person(
(sex == "M" &&
p1.sex == "F") || (sex == "F" && p1.sex == "M")
)
() are optional and && has higher priority than ||.
We already updated docs for such things in the manual. I would like to ask you to read and please provide feedback and even patches for parts of the text that eventually are not clear:
http://labs.jboss.com/file-access/default/members/drools/freezone/docs/4.0.0.13773GA/html/index.html
Section 6.5.2.
[]s
Edson
2007/7/25, Yuri <ydewit@gmail.com>:
I am migrating my 3.0.6 rules into 4.0 but I am getting the following error in
Drools IDE:
"Trying to create a restriction for an empty restriction"
I am basically using an inline-eval (I believe this is the new terminology for
the ->() construct):
Rule
when
c1:Child()
c2:Child(
age -> (Math.abs(age - c1.age) < 10),
...)
then
...
end
If I remove the "age -> ..." line the error goes away.
Along the same lines I am also wondering if there is a better way (aside from
using "->()", which has a lower perf as I understand it) of doing the following:
Rule
when
p1: Person()
p2: Person(
...,
sex -> (
(sex == "M" && p1.sex == "F")
|| (sex == "F" && p1.sex == "M")
)
)
then
insert(new Couple(p1, p2));
end
thanks,
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com