Marc Knaup
10/04/2019, 7:26 AMsomeFuncReturningBool() && otherFuncReturningBool() and someFuncReturningBool() and otherFuncReturningBool() is not the same. The former short-circuits, the latter doesn’t.
That hit me unexpectedly when I thought “oh that’s nice, I can just use and instead of && in my DSL to make it more human-readable”.
rule {
condition {
terms.assignmentAddress.isProvided() and
terms.assignmentAddress.country.isNotSupported() // exception because access not allowed if isProvided() returns false
}
issue {
"Terms: The address of the assignment is located in a country that is not supported."
}
}
I presume there are only two ways to fix this.
a) Use && instead of and 😥
b) Make all the functions which can be used in condition {} that currently return Boolean return something like Condition instead. That in turn would have an and infix operator which makes two Condition instances form a new Condition and thus allows for chaining with and. That would basically build a tree of Condition.
I guess there are no alternatives for supporting and here?efemoney
10/08/2019, 12:46 AMand is a bitwise operator not a boolean operator.Marc Knaup
10/08/2019, 3:29 AMBoolean, hence the confusion :)