From: Simon Wright <simon.j.wright@mac.com>
Subject: Re: Generic Collection
Date: Sat, 12 May 2007 08:18:09 +0100
Date: 2007-05-12T08:18:09+01:00 [thread overview]
Message-ID: <m2y7ju1pe6.fsf@mac.com> (raw)
In-Reply-To: 1178837285.391940.192010@e65g2000hsc.googlegroups.com
andrew <andrew.carroll@okstate.edu> writes:
> So I think you are saying I would have one Collection package and it
> has three procedures called Add and they operate on three different
> types:
> Tuple
> Table
> Schema
>
> but then how do I later use the collection package for some other
> purpose?
I would probably end up with a package for each, with appropriate Add
operations.
with Tuples;
package Tables is
type Table is private;
procedure Add (To : in out Table; Item : Tuples.Tuple);
...
private
...
package Tuple_Containers
is new <generic-container-package> (Items => Tuples.Tuple);
type Table is record
Items : Tuple_Containers.Container;
...
end record;
...
where you get the fun of choosing which generic-container-package to
use (Ada.Containers would be a good start) or writing your own.
I can't see what possible advantage you'd get from being able to add a
Colour to a Schema! If you make a container that can contain anything
you will need to have runtime checks to enforce this sort of rule
rather than compile-time checks. Elsewhere in this thread you seemed
to scoff at this as being a concern; I think classwide programming
ought to be restricted to the places where it brings you an advantage
rather than being something that makes your life difficult.
next prev parent reply other threads:[~2007-05-12 7:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-08 19:29 Generic Collection andrew
2007-05-08 21:00 ` Georg Bauhaus
2007-05-08 21:59 ` andrew
2007-05-09 14:51 ` andrew
2007-05-09 16:12 ` Georg Bauhaus
2007-05-09 18:54 ` andrew
2007-05-10 19:31 ` Simon Wright
2007-05-10 22:48 ` andrew
2007-05-11 8:10 ` Georg Bauhaus
2007-05-11 20:41 ` andrew
2007-05-11 21:28 ` Georg Bauhaus
2007-05-11 21:55 ` andrew
2007-05-12 7:18 ` Simon Wright [this message]
2007-05-12 7:52 ` Dmitry A. Kazakov
2007-05-13 11:00 ` Simon Wright
2007-05-13 12:11 ` Dmitry A. Kazakov
2007-05-16 0:27 ` Randy Brukardt
2007-05-16 6:05 ` Simon Wright
2007-05-16 7:17 ` Untagged types don't work right - was: " Grein, Christoph (Fa. ESG)
2007-05-16 13:27 ` Benjamin Place
2007-05-14 17:09 ` andrew
2007-05-14 20:00 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox