Re: EuCOM : Attn Matt : String Return Value
- Posted by Pete Lomax <petelomax at bl?ey?nder.co.uk> Oct 09, 2007
- 702 views
Matt Lewis wrote: > > Actually, namespaces will be inherited (and are inherited, for code at the > head of the svn repository) in the next release. I typically run this > code, which is probably why I haven't noticed the bug. Cool. How did you solve that in the end? In Positive I devised a set of priority tables, which is quite simple really but harder to explain, eg: -- fileno desc parents priorities -- 1 inc7 {} {2,1,1,1,1,1} -- 2 eric {1} {2,4,3,3,3,3} -- 3 bob {2} {2,4,6,5} -- 4 alice {3} {2,4,6,8} -- 5 diane {2} {2,4,4,4,10,9} -- 6 chris {5} {2,4,4,4,10,12} So in bob (hence using priorities[3]), after alice has been included, if there are multiple global X then one in file 3 (bob, priority 6) is the first choice, then one in file 4 (alice, priority 5), then eric, then inc7. (I trust everyone agrees that is how it should behave.) Likewise in eric (hence using priorities[2]), after bob/alice/diane/chris have been included, then if there is an X in file 2 (eric, priority 4), use that, else if one (*and only one*) in bob/alice/diane/chris, priority 3, use that else inc7. An include extends the parent(s) with priorities[p,p]-1, eg "include bob" extends priorities[2] from {2,4} to {2,4,3}, and "include alice" extends priorities[3] from {2,4,6} to {2,4,6,5} and priorities[2] from {2,4,3} to {2,4,3,3}. Lots of numbers but quite simple to do in practice. A new file copies the parent promoting sub-includes to parent priority, eg "include diane" begins by copying eric's {2,4,3,3} to {2,4,4,4} and adding a new high priority (simply 2*idx, here 10) for itself, before as above extending eric's to {2,4,3,3,3} and inc7's to {2,1,1,1,1}. Again this may look more complex than it is. For namespace handling, just ignore any files with priority < [p,p]-1, eg after "include bob as bob", then bob:xx looks up xx using priorities[3], ie {2,4,6,5} but ignoring anything of lower priority than 5, hence only looking in bob and alice, not eric and inc7. No doubt there will be some detractors, but I'm quite proud of that design as it allows a single pass through the (single) global table, keeping track of the highest priority and trivially discarding any lower previously found, plus simply making a note of the priority adds minimal cost to the single instance case. Whether that scheme could be used in eu.ex is another matter. Regards, Pete