Hmmmmm....<br><br>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:-<br>
<br><code>rule</code>
<code>outputinput<br>
</code><code>when</code>
<div><code> </code><code>Here( loc : location) </code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food : ?, </code><code>loc</code><code>;)</code></div>
<div><code>then</code><br>
System.out.println("Food " + food + " at location " + loc);<br>
// Output:<br>
// Food crackers at location kitchen<br>
// Food apple at location kitchen</div>
<div><code>end<br>
</code><br>
<div><code>rule</code>
<code>outputOutput<br>
</code><code>when</code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food : ?, </code><code>loc : ?</code><code>;)</code></div>
<div><code>then</code><br>
System.out.println("Food " + food + " at location " + loc);<br>
// Output:<br>
// Food crackers at location kitchen<br>
// Food apple at location kitchen<br>
// Food chocolate at location living room<br>
// Food chips at location living room
</div>
<div><code>end<br>
<br>
</code>
<div><code>rule</code> <code>typo<br>
</code><code>when</code></div>
<div><code> </code><code>Here( looc : location) </code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food : ?, </code><code>loc : ?</code><code>;)</code></div>
<div><code>then</code><br>
System.out.println("Food " + food + " at location " + loc);<br>
// Output:<br>
// Food crackers at location kitchen<br>
// Food apple at location kitchen<br>
// Food chocolate at location living room<br>
// Food chips at location living room<br> // looc is just an unused bound variable<br></div>
<div><code>end</code></div></div></div><br><br><div class="gmail_quote">On 20 April 2011 10:16, Geoffrey De Smet <span dir="ltr"><<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div text="#000000" bgcolor="#ffffff">
Mark and I were discussing backwards chaining<br>
<a href="http://blog.athico.com/2011/04/backward-chaining-emerges-in-drools.html" target="_blank">http://blog.athico.com/2011/04/backward-chaining-emerges-in-drools.html</a><br>
on IRC and we 'd like your opinion on a design issue.<br>
<br>
The example<br>
========<br>
<br>
Let's say you have this data:<br>
Location("crackers", "kitchen")<br>
Location("apple", "kitchen")<br>
Location("chocolate", "living room")<br>
Location("chips", "living room")<br>
<br>
Let's say you have this code:<br>
<br>
<div><code>query</code>
<code>editableThings( String thing, String
location ) </code></div>
<div><code> </code><code>Location(thing, location)</code></div>
<div><code>end</code></div>
<br>
And then these 3 rules:<br>
<br>
<div><code>rule</code>
<code>outputinput<br>
</code><code>when</code></div>
<div><code> </code><code>Here( loc : location) </code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food, </code><code>loc</code><code>;)</code></div>
<div><code>then</code><br>
System.out.println("Food " + f + " at location " + loc);<br>
// Output:<br>
// Food crackers at location kitchen<br>
// Food apple at location kitchen</div>
<div><code>end<br>
</code><br>
<div><code>rule</code>
<code>outputOutput<br>
</code><code>when</code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food, </code><code>loc</code><code>;)</code></div>
<div><code>then</code><br>
System.out.println("Food " + f + " at location " + loc);<br>
// Output:<br>
// Food crackers at location kitchen<br>
// Food apple at location kitchen<br>
// Food chocolate at location living room<br>
// Food chips at location living room
</div>
<div><code>end<br>
<br>
</code>
<div><code>rule</code> <code>typo<br>
</code><code>when</code></div>
<div><code> </code><code>Here( looc : location) </code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food, </code><code>loc</code><code>;)</code></div>
<div><code>then</code><br>
System.out.println("Food " + f + " at location " + loc);<br>
// Output:<br>
// Food crackers at location kitchen<br>
// Food apple at location kitchen<br>
// Food chocolate at location living room<br>
// Food chips at location living room</div>
<div><code>end</code></div>
<br>
</div>
<br>
</div>
The discussion<br>
=========<br>
<br>
Both rules have the same statement:<br>
<code>?</code><code>editableThings</code><code>(food, </code><code>loc</code><code>;)</code><br>
<br>
<code></code>In the outputInput rule, "<code></code><code>loc</code><code></code>" is an input variable.<br>
<code></code>In the outputOutput rule, "<code></code><code>loc</code><code></code>" is an output variable.<br>
<br>
I am wondering if we don't need a visual demarcation that a variable
is an output variable,<br>
to make it stand out of an input variable?<br>
<br>
Proposition 1: Suffix output variables with ":"<br>
<br>
<div><code>rule</code>
<code>outputinput<br>
</code><code>when</code></div>
<div><code> </code><code>Here( loc : location) </code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food:, </code><code>loc</code><code>;)</code></div>
<div><code>then
... end<br>
<br>
</code>
<div><code>rule</code>
<code>outputOutput<br>
</code><code>when</code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food:, </code><code>loc:</code><code>;)</code></div>
<div><code>then
... end</code><code></code></div>
<br>
<div><code>rule</code>
<code>typo<br>
</code><code>when</code></div>
<div><code> </code><code>Here( looc : location) </code></div>
<div><code> </code><code>?</code><code>editableThings</code><code>(food:, </code><code>loc</code><code>;) // compiler error because input variable
loc is not declared</code><code></code>
<div><code>then ... end</code></div>
</div>
</div>
<br>
<br>
-- <br>
With kind regards,<br><font color="#888888">
Geoffrey De Smet
</font></div>
<br>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br></blockquote></div><br>