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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86a457a80a9f4412 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!xara.net!gxn.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Generic Collection Date: Sat, 12 May 2007 08:18:09 +0100 Organization: Pushface Message-ID: References: <1178652593.006083.173150@l77g2000hsb.googlegroups.com> <1178658022.9164.17.camel@kartoffel> <1178661586.585164.191690@e51g2000hsg.googlegroups.com> <1178722277.733981.6200@l77g2000hsb.googlegroups.com> <1178727131.9164.38.camel@kartoffel> <1178736886.994385.37140@y80g2000hsf.googlegroups.com> <1178837285.391940.192010@e65g2000hsc.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1178954296 1506 62.49.19.209 (12 May 2007 07:18:16 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 12 May 2007 07:18:16 +0000 (UTC) Cancel-Lock: sha1:ybg43oK0LGhFnnLim/9FT/vwcTg= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (darwin) Xref: g2news1.google.com comp.lang.ada:15777 Date: 2007-05-12T08:18:09+01:00 List-Id: andrew 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 (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.