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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.etla.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Rationale for this not to compile? Date: Fri, 25 Jul 2014 14:45:49 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1cb91e6a-9e49-4bc8-bf4a-67a16a00e3a0@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1406317550 4000 69.95.181.76 (25 Jul 2014 19:45:50 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 25 Jul 2014 19:45:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: number.nntp.dca.giganews.com comp.lang.ada:187874 Date: 2014-07-25T14:45:49-05:00 List-Id: "Robert A Duff" wrote in message news:wccvbql5won.fsf@shell01.TheWorld.com... > "Randy Brukardt" writes: > >> One of my pet projects (that I don't have any time to follow up on!) is >> to >> create a useful container where the element type is a formal incomplete >> type. I think that the container would have to manage elements that live >> elsewhere (unlike Ada.Containers) -- since element creation isn't >> possible, >> but this would allow a container of limited elements, and of course would >> allow instantiation by a private type as here. > > Sounds interesting, but I don't understand what you mean by "live > elsewhere". Could you outline how this would work? I'm having trouble > seeing what use is a "container" that doesn't contain any elements. I left out one part: the elements would have to be tagged, because "tagged incomplete" allows a number of things that regular incomplete doesn't. (In particular, they're assumed to be passed by-reference, so parameters are allowed). Access after insertion would be via Reference/Constant_Reference only (can't make a copy of the element, obviously, and no functions can return the element). Anyway, you can't create an object of an incomplete type, so the client has to do that before adding it to the container. That means the container's job is to manage the relationships between the elements (and the lookup mechanism, for maps and sets). For instance, one could have a bunch of tasks, and put them into a map container in order to add a lookup mechanism to them. Something like: Tasks : array (1 .. 10) of My_Task; -- Assume My_Task is tagged. package My_Task_Map is new Randys_Super_Duper_Map_Container (String, My_Task); My_Map : My_Task_Map.Map; ... My_Map.Insert ("Bob", Tasks(1)); My_Map.Insert ("Randy", Tasks(2)); My_Map.Insert ("Tucker", Tasks(3)); My_Map.Insert ("Steve", Tasks(4)); -- My_Map("Bob").My_Entry (...); -- Entry call on the task associated with "Bob". Does this make sense? Randy.