I have a bunch of rules that need to reference the same literal value twice,
once in the LHS, and once in the RHS.  These rules will be written and
modified by end-users (using a DSL).  I don't want them to have to write the
literals twice, because it's too easy to later change only one of the
occurrences, and end up with an inconsistent rule.

I want something like this:

rule "a rule"
 when
  localValue : 7
  SomeObject( aField > localValue )
 then
  takeSomeAction(localValue)
end

Or this:

rule "a rule"
 when
  local lvalue = 7
  SomeObject( aField > lvalue )
 then
  takeSomeAction(lvalue)
end

Is there some way to do this with existing Drools syntax (or version 3.1 
syntax)?

The only think I can think of is this, which looks offensively clunky to me:

global HashMap stash;

rule "a rule"
 when
  stash.put("a rule", 7)
  SomeObject( aField > (stash.get("a rule")) )
 then
  takeSomeAction(stash.get("a rule"))
end

-- 
Dirk Bergstrom               [EMAIL PROTECTED]
_____________________________________________
Juniper Networks Inc.,          Computer Geek
Tel: 408.745.3182           Fax: 408.745.8905

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to