[rules-users] How to write DSL for relation between two objects

Flavius Vespasianus flavius at email.cz
Thu Jun 11 18:56:52 EDT 2009


Hi,

I'd like to write in my DSL in LHS questions as

rule "Relation"
when
relation between "a" and "b" is "x"
then
do something
end

The "relation between..." can be rewritten as
relation between "{var1}" and "{var2} is "{relation}" =
$a: A(name == "{var1}")
$b: A(name == "{var2}")
eval(A.getRelation($a, $b) == "{relation}")

But the problem is that if I write
when
relation between "a" and "b" is "x"
relation between "c" and "d" is "y"
then...
the variables $a and $b collide.

It could be solved as to use $a{var1} instead of $a, but this forces the 
user to use only names without spaces and special characters. And the 
bigger problem is that I still cannot write
relation between "a" and "b" is "x"
or
relation between "a" and "b" is "y"

Is there any way to make the variables "local" withing some block? Or do 
I need to force user to manually set names for those variables?

Thanks for any suggestions

Flavius



More information about the rules-users mailing list