<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’m also struggling to read and understand the original syntax and I don’t think the rest of my team would realise what was happening if I wrote something like
that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Some form of nested rules with a when … then when … else when …then … else … then … end type syntax will be much easier for people to understand what is happening
without having to understand much of the syntax. Some form of nesting will be needed to identify the scoping of matches.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The other alternative is to add the concept of a named condition
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">condition “ABC” when a : A() … end<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">rules would be able to reference conditions and access the bindings defined within there scope, this would allow you to write<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">rule “A”<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">when<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> condition “ABC”<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">then<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> print a; //a is bound in the condition<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">end<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">and for the else<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">rule “not A”<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">when<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> not condition “ABC”<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">and
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">multiple conditions could be used allowing the equivalent functionality of many else when combinations but with easier to read rules.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thomas<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> rules-dev-bounces@lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org]
<b>On Behalf Of </b>Geoffrey De Smet<br>
<b>Sent:</b> 19 August 2011 13:00<br>
<b>To:</b> rules-dev@lists.jboss.org<br>
<b>Subject:</b> Re: [rules-dev] else<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I like Mario's proposal because I can actually read it.<br>
Those special chars | < are gibberish to me.<br>
<br>
The only reason we're not debating to use a new readable, intuitive keyword, is because of the back-wards compatibility issues involved.<br>
But using unreadable, unintuitive special char just for that, is probably not a good idea.<br>
I wonder if we reserve new keywords by prefix them with reserved special char like "@"?<br>
Then we can introduce as many keywords as we want without breaking backwards compatibility.<br>
<br>
Who's our target users for DRL authors?<br>
A) Supersmart computer science guys<br>
B) Blue collar Java programmers<br>
C) Domain experts (= not programmers)<br>
<br>
I 'd classify "{notA} < A()" as (given some time to learn it) readable for A, but not for B and C.<br>
<br>
Op 18-08-11 23:35, Mario Fusco schreef: <o:p></o:p></p>
<p class="MsoNormal">Hi Mark,<br>
<br>
Since you're gathering 2 cents here and there I decided to add also mine even if I am pretty sure that I am still missing the whole picture and anyway at the moment I cannot see all the consequences of what I am going to propose.<br>
<br>
To tell you the truth I find the label syntax not very intuitive and I was wondering if we could avoid it in some way. In the end what the 90% of the users are asking for is just something like:<br>
<br>
rule R<br>
when<br>
A()<br>
then<br>
do something<br>
else<br>
do something else<br>
end <br>
<br>
while we are going to give them something that is not exactly the same:<br>
<br>
rule R<br>
when<br>
{notA} < A()<br>
then<br>
do something<br>
then.notA<br>
do something else<br>
end <br>
<br>
In particular I was thinking if we could keep the when ... then ... else syntax that should be familiar to the biggest part of the users and at the same time obtain a flexibility similar to the one provided by the labels syntax. Probably we could do it with
a kind of nested rules so, for instance, the rule:<br>
<br>
rule R1<br>
when<br>
{af} < A() > {at}<br>
B()<br>
then<br>
DO<br>
<a href="http://then.af">then.af</a><br>
DO.af<br>
<a href="http://then.at">then.at</a><br>
DO.at<br>
end<br>
<br>
could be rewritten as it follows:<br>
<br>
rule R1<br>
when<br>
B()<br>
then<br>
DO<br>
rule R1A<br>
when<br>
A()<br>
then<br>
DO.at<br>
else<br>
DO.af<br>
end <br>
end <br>
<br>
Of course the nested rule couldn't be used by the Drools engine as it is, but we could implement a kind of "linearization" process at compile time that translates it more or less as:<br>
<br>
rule R1_1<br>
when<br>
A()<br>
B()<br>
then<br>
DO<br>
DO.at<br>
end<br>
<br>
rule R1_2<br>
when<br>
not A()<br>
B()<br>
then<br>
DO<br>
DO.af<br>
end<br>
<br>
In the same way the "or" example:<br>
<br>
rule R1<br>
when<br>
( A() > {a1} or<br>
B() > {b1} or<br>
C() > {c1} )<br>
D()<br>
then<br>
DO<br>
then.a1<br>
DO.a1<br>
then.b1<br>
DO.b1<br>
then.c1<br>
DO.c1<br>
end<br>
<br>
could be written as:<br>
<br>
rule R1<br>
when<br>
D()<br>
then<br>
DO<br>
rule R1A<br>
when<br>
A()<br>
then<br>
DO.a1<br>
end <br>
rule R1B<br>
when<br>
B()<br>
then<br>
DO.b1<br>
end <br>
rule R1C<br>
when<br>
C()<br>
then<br>
DO.c1<br>
end<br>
end <br>
<br>
and then linearized at compile time in a similar way as I wrote before.<br>
<br>
Once again I still haven't evaluated all the implications of my suggestion neither I know if we can cover with it all the cases proposed by Mark. I am pretty sure I am missing something important to be honest, but since we are in a "brainstorming phase" I thought
it could worth to consider it at least.<br>
<br>
My 2 cents,<br>
Mario<br>
<br>
<br>
<o:p></o:p></p>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>rules-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><o:p></o:p></pre>
<pre><a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><o:p></o:p></pre>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>-- <o:p></o:p></pre>
<pre>With kind regards,<o:p></o:p></pre>
<pre>Geoffrey De Smet<o:p></o:p></pre>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data
may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</body>
</html>