[rules-users] Finicky eval statements

Edson Tirelli tirelli at post.com
Wed Dec 10 12:45:18 EST 2008


      Is your inline eval() time-constant? I would guess that "howOld()" is
returning different values when executed at different times. Inline evals
MUST be time-constant. Top level evals can deal with non-time-constant
expressions.

      []s
      Edson

2008/12/10 Bagwell, Allen F <afbagwe at sandia.gov>

>
> I'm puzzled over the proper use of in-line evals.  I've used them
> successfully in some places. But it seems that on occasion something doesn't
> work when I think it should.
>
> First, this is a when clause that works properly using a separate eval
> statement. The rule activates and fires when expected:
>
> $rt : RuleTimer(uniqueName == "Hardware Status Request", timedOut == true)
> $hw : Hardware($activelyMonitored : activelyMonitored, command == null)
>       AttrBoolean(this == $activelyMonitored, currentValue == true)
>       eval($hw.getStatusRequested().howOld() > $hw.getStatusPeriod())
>
>
> However, this re-write changing to an in-line eval never fires.
>
> $rt : RuleTimer(uniqueName == "Hardware Status Request", timedOut == true)
> $hw : Hardware($activelyMonitored : activelyMonitored, command == null,
> eval(statusRequested.howOld() > statusPeriod) )
>       AttrBoolean(this == $activelyMonitored, currentValue == true)
>
> Likewise, this re-write doesn't fire either where I sought to bind the more
> complex statusRequested object to a Drools variable before using it in the
> eval. The field statusPeriod just holds a primitive double.
>
> $rt : RuleTimer(uniqueName == "Hardware Status Request", timedOut == true)
> $hw : Hardware($activelyMonitored : activelyMonitored, $sr :
> statusRequested, command == null,
>                eval($sr.howOld() > statusPeriod) )
>       AttrBoolean(this == $activelyMonitored, currentValue == true)
>
> I haven't been able to find anything in the manual that says these other
> two syntaxes are wrong. Furthermore, the Drools compiler has no issues with
> them.
>
> Thanks!
>
> Allen F. Bagwell
> e-mail:  afbagwe at sandia.gov
> phone:  505/284-4517
> fax:  505/ 844-7886
>
> Ask your doctor if medical advice from a TV commercial is right for you.
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081210/18f4540b/attachment.html 


More information about the rules-users mailing list