|
|
Re: Replace conditional statements with queries [message #1850116 is a reply to message #1850066] |
Wed, 16 February 2022 17:37 |
John Henbergs Messages: 239 Registered: October 2020 |
Senior Member |
|
|
Hi Christopher,
Thank you for your answer. Based on this, I have one additional question.
If you look at my example using if/else, pretend I have another rule
mapping MMA:: X :: X2Y : MMB: Y
disjuncts EL1: : EL1toEL2(), //and some other rules
Now, if instead of using if/else, I do as you suggested (using disjunct), which is the right way to write the X2Y mapping?
mapping MMA:: X :: X2Y : MMB: Y
disjuncts EL1: : EL1toEL2() (where EL12EL2 disjuncts two other rules) // some other rules
or
mapping MMA:: X :: X2Y : MMB: Y
disjuncts EL1 :: SingleEL1toEL2, EL1 :: MultipleEL1toEL2, //some other rules.
Many thanks!
|
|
|
Re: Replace conditional statements with queries [message #1850132 is a reply to message #1850116] |
Thu, 17 February 2022 08:44 |
Christopher Gerking Messages: 115 Registered: April 2011 |
Senior Member |
|
|
Hi
John Henbergs wrote on Wed, 16 February 2022 12:37
Now, if instead of using if/else, I do as you suggested (using disjunct), which is the right way to write the X2Y mapping?
A tree of disjunctions (i.e., a disjunctive mapping that further disjuncts) is generally possible. So it depends on how much reusability you like or require. If you have a separate EL1: : EL1toEL2 mapping (that is disjunctive itself), you can reuse that mapping from other places. For example, you can invoke or resolve it separately, or use it as part of another disjunction. From your snippet, it's hard to tell whether your transformation could actually benefit from that.
Another criterion is readabilty. I usually like to avoid long lists of disjunctions in favor of a deeper, tree-like nesting (which also ensures maximum reusability). But that's probably a matter of taste, others might find it more intuitive to have a single long list.
Kind regards
Christopher
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02828 seconds