[rules-dev] 2nd call: Summary of all new features in DSL - comments, please

Edson Tirelli ed.tirelli at gmail.com
Mon Jan 3 10:18:23 EST 2011


   Hi Wolfgang,

   It looks very good. My only concern is how it affects the eclipse
plugin, specially the line breaks. I am guessing we will have to
change it to support that?

   Also, does any of these changes break backward compatibility?

   In case it doesn't, my vote is to apply all the changes listed.

   Edson


2011/1/3 Wolfgang Laun <wolfgang.laun at gmail.com>:
> Probably sent not at the best of times, this didn't get a peep from anyone.
> Please do comment, for the reasons stated below.
> -W
>
> On 24 December 2010 11:23, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
>>
>> This is a summary of the currently implemented new features for the DSL
>> expansion. I'll have to add tests and documentation, but before doing so,
>> I'd like to learn whether there are any objections (resulting in the
>> removal) or suggestions for improvement. Myself, I'm not sure about one or
>> two items which I've marked with "(?)". Also, there's a couple of items
>> which might gain from easy-to-implement additions, see "Votes, please". An
>> example showing most of the new options is given below.
>>
>> The right hand side of entry definitions can be empty. (Useful for
>> deleting "filler" phrases.)
>> Long entry lines can be split without the need of escaping EOL:
>>
>> Any line beginning with # or // starts a DSL comment and is not passed to
>> the DSL parser.
>> Any line beginning with '[' starts a new entry.
>> All other lines are appended to the preceding line, with a space replacing
>> EOL.
>> Empty lines are inserted to maintain original line numbers, and line and
>> column numbers in error messages from the parser are recalculated to reflect
>> the user view of the DSL text.
>>
>> The special comment introduction "#/" is used to mark a line containing
>> debug options. Currently recognized keywords are:
>>
>> result - dumps the resulting DRL
>> steps - shows all expansion operations in conditions and consequences
>> keyword, when, then - display the corresponding entry definitions
>> usage - shows how often an entry was actually used in an expansion
>>
>> Variable substitution uses the definition of that variable seen last in
>> the current when or then part expansion. not just from the current line.
>> (But this probably should keep variables from the when part for the
>> following then part. Votes, please.)
>> The value used in a variable substitution can be modified on the fly by
>> adding one of the modifiers after and '!' in the variable reference.
>> Currently recognized modifiers are:
>>
>> uc, lc - convert all letters to upper case or lower case, respectively
>> ucfirst - convert the first letter to upper case, and all other letters to
>> lower case
>> num - extract all digits and a '-' preceding the first digit and insert
>> the numeric value; a '.' or ',' two digits from the right is retained as a
>> decimal point, which is useful for monetary quantitites. (?)
>>
>> Another modification of the value used for substituting the reference is
>> by providing a "multiple choice" after an '!', consisting of strings
>> separated alternatively by '?' and '/': If the string extracted from the
>> DSLR line matches the string before a '?', the string following it is used
>> for substitution; otherwise test the next choice. (?)
>> A DSL value starting with a hyphen ('-') can also be used in a consequence
>> to add another setter expression into a preceding "modify(x){}". (Should
>> probably be extended to be able to handle the insertion of another parameter
>> to any preceding method call and, as a special, but useful, case the
>> concatenation to a preceding x.println() or x.print() call. Votes, please.)
>>
>> DSL:
>> [when][][Tt]here is an?=
>> [when][]{entity} called {x}=
>>         ${entity!lc}: {entity!ucfirst}( $name:
>> name=="{x!M?Mark/E?Edson/G?Geoffrey/unknown}")
>> [when][]and no other with the same {attr}=not {entity!ucfirst}( {attr} ==
>> ${attr} )
>> [then][]change person=modify($person)\{\}
>> [then][]- set {attr} to {value} = set{attr!ucfirst}( {value!num} )
>>
>> DSLR:
>> rule "Rule 1"
>> when
>>     There is a PERSON called M
>>     and no other with the same name
>> then
>>     change person
>>     - set salary to US$9,999.99
>>     - set rank to "colonel"
>> end
>>
>> DRL:
>>    8  rule "Rule 1"
>>    9  when
>>   10  $person: Person( $name: name=="Mark")
>>   11  not Person( name == $name )
>>   12  then
>>   13  modify($person){ setSalary( 9999.99 ), setRank( "colonel" ) }
>>   14  end
>>
>> Cheers
>> Wolfgang
>>
>>
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com



More information about the rules-dev mailing list