[Adobe-source-devel] property models with multi-out relationships From: Sean Parent - 2010-05-25 19:56:30 ```A couple of days ago I found a bug in my flow algorithm where I wasn't marking edges correctly (fix prior to my latest submit). In fixing that, it dawned on me how multi-out relationships should work. I just checked in a first cut of this to my sandbox. Here's what I did. You can now have multiple values on the lhs of a relate expression (comma separated) and if you have more than one item, the expression on the right must yield an array with the same number of items as is on the left: relate { a, b <== [c, d]; c, d <== [a, b]; } For this cut, a cell can only appear once on the lhs for all terms in the relate clause (a limitation because of how I'm simulating marking edges instead of actually marking edges... I'm a little unsure about the correct way to handle this case but I think it should be simple with some better data structures). To flow the graph through this relate clause, if I enter the clause through one value (let's say "a") then any term with "a" on the lhs is disqualified as an out. When there is only one term remaining, flow continues through the lhs cells of that term and any cells named on the lhs that aren't already marked as in or out are marked as in. So if a has a high priority in this example, then we only have the c,d term to flow out of and b gets marked as an in edge. Note that we only know at that point that b is an input to the relate, we don't know how the value of b is determined. The old hack to simulate used to "back- flow" into b screwing up the contributing values. For example, if you had: relate { a, b <== [c, d]; c, d <== [a, b]; } relate { b <== e; e <== b; } Then if a has the highest priority then it will contribute to c and d along with either b or e (depending on which was higher). The result is you can do multi-out relationships without screwing up script recording. Here is the full grouped options example done the old way with the self-reference hack: --- sheet grouped_options { interface: a : true; b : true; c : true; g : [a, b, c]; all; constant: g_true : [true, true, true]; g_false : [false, false, false]; logic: relate { a <== g[0]; g <== [a, g[1], g[2]]; } relate { b <== g[1]; g <== [g[0], b, g[2]]; } relate { c <== g[2]; g <== [g[0], g[1], c]; } relate { all <== g == g_true ? true : g == g_false ? false : empty; g <== [all, all, all]; } output: result <== { a: a, b: b, c: c }; } --- Here it is the new way: --- sheet grouped_options { interface: a : true; b : true; c : true; all; logic: relate { all <== a == b && b == c ? a : empty; a, b, c <== [all, all, all]; } output: result <== {a: a, b: b, c: c}; } --- Now you can do things like CMYK to RGB conversions simply (and correctly). Yea! Not bad for an hour of hacking... Sean ```