Adding new keywords is not as impossible as it might seem. It depends on the place the new keyword should appear. Almost all keywords are now recognized depending on the symbol(s) before or after. This makes the parser somewhat vulnerable w.r.t. garbage input token sequences, but there's no way around that.
As for the "acc" proposal itself, I find that
dontCallItAcc( Foo( $x:x ...);
$max: min($x), $min: max($x);
$max - $min > 100 )
as a CE is not declarative enough. If I'd like to do the same thing for a Bar(), I'd have to write it all over again. For instance, if there were a
declare MinMax( Number n )
min : Number from min( n );
max : Number from max( n )
end
I might use this in more than one place:
Foo( $x: x ) | MinMax( $x )( max - min > 100 )
Bar( $y: y ) | MinMax( $y )( max - min > 200 )
-W
Op 20-08-11 00:42, Mark Proctor schreef:I am not against adding new features to the language. (*)On 19/08/2011 12:42, Geoffrey De Smet wrote:"Good programmers appreciate what you put in, Great programmers appreciate what you leave out " -- Josh Bloch I also believe that having 2 accumulates is just going to bring confusion and complexity.Over time we'll deprecate the old accumulate. But we must evolve the language to improve it, it's not easier as there is no one to copy for this, it's virgin territory. That means we can't be afraid to try things, and change them if think we can improve it. Mark
But don't call it "acc" or "accumulate", that will just confuse everyone.
Call it "gather", collect, hoard, amass, pileUp, cumulate, conglomerate, ... anything but accumulate or an abbreviation.
http://www.thefreedictionary.com/accumulate
Using the same term for 2 different things greatly disrupts communication (= API, manual, code readability, ...).
The 2 WorkingMemory (= same term for 2 different things) are still causing confusion:
org.drools.WorkingMemory
org.drools.runtime.rule.WorkingMemory
You can even mix them in your code (several planner examples did that for a couple of years before I noticed it).
Let's investigate ways to clean that up first? For example: move the old one to drools-core-legacy-api already, before we completely remove it.
With kind regards, Geoffrey De Smet
(*) I do believe we need a more future proof system of adding keywords and features. I see 2 alternatives:
A) Specify a drlModel version in the DRL. This allows backwards incompatible changes between drlModel versions, but new drools jars should still support the last 3 drlModel versions. This is similar to:
-- pom.xml's <modelVersion>4.0.0</modelVersion>
B) Find a way to reserve keywords.
-- By having to import the keywords?
import keyword org.drools.parser.acc; // I can now use acc in my rules
import keyword org.drools.parser.thenElse; // I can now use thenElse in my rules
-- By prefixing the keywords with a reserved character.
For example: @acc, @thenElse or #acc, #thenElse
-- Like Ceylon, by layout (probably not possible): "Note also that annotations like doc, by, see, and deprecated aren't keywords. They're just ordinary identifiers. The same is true for annotations which are part of the language definition: abstract, variable, shared, formal, actual, and friends. On the other hand, void is a keyword. "
--
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev