From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,FROM_WORDY, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f071b0868ee342f X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: Design Question: How Best To Structure Cross-Referencing Types In Ada 95 Date: 1999/01/30 Message-ID: <78vonc$793$1@plug.news.pipex.net>#1/1 X-Deja-AN: 438793094 References: <36A68FCA.E1EEAFFE@hiwaay.net> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom) Newsgroups: comp.lang.ada Date: 1999-01-30T00:00:00+00:00 List-Id: Great minds must think alike! (He says modestly :-) I was _just_ about to suggest (more or less) the same solution. Matthew says "You have to ...": I would suggest that this is a _possible_ solution, rather than _the_ solution. It might (but not necessarily) be appropriate to organise the packages a little, e.g. by making Cars, Parts etc. children of Root_Cars. As a tiny matter of style, you might want to choose names thusly: "Cars" instead of "Root_Cars", and then "Ford_Cars", "GM_Cars", "BMW_Cars", "Ford_Parts", "Lucas_Parts", etc. instead of "Cars", "Parts", etc. (i.e. the children packages with derived types are progressively _specialising_). [I've no doubt Matt chose the names he did to simplify the example.] This design (with tagged types) gives you the extensibility that OO people are always banging on about: you can add a new type of car or part without (in general) having to recompile any of the other packages. On larger systems this can help prevent you wearing your teeth down on the edge of the desk (waiting to recompile). In implementation terms, the tag check costs about 5-10 instructions, and about 2-4 clock ticks for success (on a typical modern 32-bit processor, with Optimise(Time) in force, excluding crap compilers). Unless you have a really good reason not to, I would suggest you just live with this check: it is likely to save you being skewered by a deep bug one day. ------------------------------------------- Nick Roberts ------------------------------------------- Matthew Heaney wrote: a tagged-type solution to Tony's problem.