<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008>(Monday morning, back in the
office.)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008>Ah, thanks! I took out the final keywords and
sure enough, it works.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008>Read the page link you provided. Good info there. I
hadn't really delved into shadow facts much yet. Thanks for clearing this
up!</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008>:-)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=113010813-28042008>-A</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Edson
Tirelli<BR><B>Sent:</B> Friday, April 25, 2008 1:11 PM<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> Re: [rules-users] When is eval
unavoidable?<BR></FONT><BR></DIV>
<DIV></DIV><BR> Allen, <BR><BR> The problem
is that you are making your methods "final". When you make your methods final,
the shadow proxy can't intercept them to ensure working memory consistency. In
your example, just removing the final modifier from your methods make them work
as expected.<BR><BR> If it is of any help, you can completely
disable shadow facts by following the instructions in the manual or in this
post:<BR><BR><A
href="http://blog.athico.com/2008/02/shadow-facts-what-you-always-wanted-to.html">http://blog.athico.com/2008/02/shadow-facts-what-you-always-wanted-to.html</A><BR><BR>
Also, the algorithm used in drools 5 will not require shadow facts
anymore.<BR><BR> The reason eval works in your example is that
it bypass shadow facts.<BR><BR> []s<BR>
Edson<BR><BR><BR>
<DIV class=gmail_quote>2008/4/25 Bagwell, Allen F <<A
href="mailto:afbagwe@sandia.gov">afbagwe@sandia.gov</A>>:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>I forgot
to mention...</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>Drools
4.0.4 (the pre-compiled jars downloaded from the Drools web
site)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>Running on
HP ProLiant/RedHat Enterprise 4.</SPAN></FONT></DIV>
<DIV class=Ih2E3d>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>-A</FONT></SPAN></DIV><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of
</B>Edson Tirelli<BR><B>Sent:</B> Thursday, April 24, 2008 3:54
PM<BR><B>To:</B> Rules Users List<BR><B>Subject:</B> Re: [rules-users] When is
eval unavoidable?<BR></FONT><BR></DIV>
<DIV></DIV><BR></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c> Allen,<BR><BR> Both your examples
must work just fine:<BR><BR>$b : Y(running == true)<BR><BR>// attempting to
find all applicants named Bob<BR>$p : Person(firstName == "Bob")<BR>$ap :
Applicant(person == $p)<BR><BR> I can't think about a reason
for them to not work. If they aren't, can you please provide a self contained
test case for us to evaluate?<BR><BR> Answering your
question, in Drools 4, assuming your facts are beans, there should be almost
no reason for you to fall back into an eval. The usage of eval is usually
related to the need for calculation inside a constraint or the call of
functions.<BR><BR> []s<BR> Edson<BR><BR>
<BR><BR><BR>
<DIV class=gmail_quote>2008/4/24 Bagwell, Allen F <<A
href="mailto:afbagwe@sandia.gov" target=_blank>afbagwe@sandia.gov</A>>:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">I'm
learning how to use Drools, but eval presents a problem to me when I am
composing rules. I've read the manual and have a basic understanding of what
it is for (very useful in certain situations!), but is there a better
explanation of when it cannot be avoided?<BR><BR>For example when writing
the LHS portion of a rule, I've run into a problem where literal
restrictions alone are fine for one object but inadequate for another.
Like so:<BR><BR>$a : X(temp < 100)<BR><BR>$b : Y(running ==
true)<BR><BR>In both cases class X and class Y have standard Java bean set
up for these fields with appropriate getters and setters, and the
corresponding inserted facts see these fields being updated from time to
time. But whereas the first fact causes rule activation when the temp field
meets the rule critiera, the second will never work unless it is re-written
as:<BR><BR>$b : Y()<BR>eval ($b.isRunning() == true)<BR><BR><BR>I've
encountered a similar problem with in-line evals where Drools will accept an
LHS like this:<BR><BR>// attempting to find all applicants named Bob<BR>$p :
Person(firstName == "Bob")<BR>$ap : Applicant(person == $p)<BR><BR>but it
will never cause activation unless you re-write it like this:<BR><BR>$p :
Person(firstName == "Bob")<BR>$ap : Applicant( eval(person == $p)
)<BR><BR>despite the fact that the Applicant object's person field once set
never changes.<BR><BR>So is there a more definitive explanation as to why
one is forced to use eval when you would think that simple literal
restrictions would be enough? I've read in other posts that "eval is
evil" and to best avoid it unless necessary, but this is perplexing me
because I haven't yet discovered the way to think about rule composition
that prevents eval use from appearing to be arbitrary. Mostly it's been
write what I think *should* work and if it does then great, it if doesn't
then keep adding evals until it does. For the record, I'm using the java
dialect if that makes a
difference.<BR><BR>Thanks!<BR><BR>-Allen<BR><BR><BR><BR><BR><BR>_______________________________________________<BR>rules-users
mailing list<BR><A href="mailto:rules-users@lists.jboss.org"
target=_blank>rules-users@lists.jboss.org</A><BR><A
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Edson Tirelli<BR>JBoss Drools Core Development<BR>Office:
+55 11 3529-6000<BR>Mobile: +55 11 9287-5646<BR>JBoss, a division of Red Hat @
<A href="http://www.jboss.com" target=_blank>www.jboss.com</A>
</DIV></DIV></DIV><BR>_______________________________________________<BR>rules-users
mailing list<BR><A
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Edson Tirelli<BR>JBoss Drools Core Development<BR>Office:
+55 11 3529-6000<BR>Mobile: +55 11 9287-5646<BR>JBoss, a division of Red Hat @
<A href="http://www.jboss.com">www.jboss.com</A> </BODY></HTML>