Hmmmmm....
Personally, I don't like the use of ":" i isolation as it's what we currently use to bind variables and I feel "cheese:" as an output definition could just make people question whether they've missed something. Perhaps "cheese : ?" would be a viable alternative. This would be in keeping with (a) current variable declaration, (b) the use of "?" to identify a call to a query. Geoffrey's examples would then become:-
rule
outputinput
when
Here( loc : location) ?editableThings(food : ?, loc;)thenend
rule
outputOutput
when ?editableThings(food : ?, loc : ?;)thenend
rule typo
when Here( looc : location) ?editableThings(food : ?, loc : ?;)thenendMark and I were discussing backwards chaining
http://blog.athico.com/2011/04/backward-chaining-emerges-in-drools.html
on IRC and we 'd like your opinion on a design issue.
The example
========
Let's say you have this data:
Location("crackers", "kitchen")
Location("apple", "kitchen")
Location("chocolate", "living room")
Location("chips", "living room")
Let's say you have this code:
queryeditableThings( String thing, String location )Location(thing, location)end
And then these 3 rules:
ruleoutputinput
whenHere( loc : location)?editableThings(food,loc;)then
System.out.println("Food " + f + " at location " + loc);
// Output:
// Food crackers at location kitchen
// Food apple at location kitchenThe discussionend
ruleoutputOutput
when?editableThings(food,loc;)then
System.out.println("Food " + f + " at location " + loc);
// Output:
// Food crackers at location kitchen
// Food apple at location kitchen
// Food chocolate at location living room
// Food chips at location living roomend
ruletypo
whenHere( looc : location)?editableThings(food,loc;)then
System.out.println("Food " + f + " at location " + loc);
// Output:
// Food crackers at location kitchen
// Food apple at location kitchen
// Food chocolate at location living room
// Food chips at location living roomend
=========
Both rules have the same statement:
?editableThings(food,loc;)
In the outputInput rule, "loc" is an input variable.
In the outputOutput rule, "loc" is an output variable.
I am wondering if we don't need a visual demarcation that a variable is an output variable,
to make it stand out of an input variable?
Proposition 1: Suffix output variables with ":"
ruleoutputinput
whenHere( loc : location)?editableThings(food:,loc;)then ... end
ruleoutputOutput
when?editableThings(food:,loc:;)then ... end
ruletypo
whenHere( looc : location)?editableThings(food:,loc;) // compiler error because input variable loc is not declaredthen ... end
--
With kind regards,
Geoffrey De Smet
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev