comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: Design Question: How Best To Structure Cross-Referencing Types In Ada 95
Date: 1999/01/30
Date: 1999-01-30T00:00:00+00:00	[thread overview]
Message-ID: <78vonc$793$1@plug.news.pipex.net> (raw)
In-Reply-To: m3r9so4j6g.fsf@mheaney.ni.net

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.







  reply	other threads:[~1999-01-30  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-20  0:00 Design Question: How Best To Structure Cross-Referencing Types In Ada 95 Anthony E. Glover
1999-01-21  0:00 ` dewar
1999-01-21  0:00   ` Brian Rogoff
1999-01-26  0:00   ` Dale Stanbrough
1999-01-21  0:00 ` dennison
1999-01-21  0:00 ` Matthew Heaney
1999-01-30  0:00   ` Nick Roberts [this message]
1999-01-31  0:00     ` Matthew Heaney
1999-01-22  0:00 ` Steve Whalen
1999-01-22  0:00   ` dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox