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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac39a12d5faf5b14 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-29 12:47:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Shared generics Date: Mon, 29 Apr 2002 14:47:26 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <5ee5b646.0204200830.2bd258d2@posting.google.com> <7wjw8.6355$Bl5.3716799705@newssvr21.news.prodigy.com> <3CC207BA.5F039C6D@adaworks.com> <3CCD5C64.2030303@mail.com> X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:23233 Date: 2002-04-29T14:47:26-05:00 List-Id: Hyman Rosen wrote in message <3CCD5C64.2030303@mail.com>... >Randy Brukardt wrote: >> Yes, Janus/Ada 95 still has shared generics. Really ugly to get right in >> Ada 95 (Ada 83 was much easier that way). > >I have a question about Ada generics. If I have understood >my text book correctly, one can instantiate a generic with >a local variable as a parameter. This is different from C++, >where a variable used as a generic parameter must be global. Yes, of course generic instantiations can be in nested scopes, and there are no restrictions on the parameters. >So it seems to me that at least some Ada generics *must* be >implemented by sharing, rather than *can* be. Depends on what you mean here. Clearly, the instantiation will be elaborated every time that the outer subprogram is called. So in that sense, the generic is 'shared'. Of course, that means that you are thinking of the subprogram body itself as 'shared' as well. That is not the conventional meaning of 'shared' when talking about generics. The basic idea is whether or not the code for the generic appears at the point of the instantiation, tailored for the parameters. Sharing occurs when two or more (textual) instantiations share part of the code for the generic unit (usually the body). This can vary from partial sharing (where what is shared depends on the parameters to the instantiation) to universal sharing (where there is only a single copy of the code for the generic unit, which is used by all instantiations). When an instantiation occurs in a subprogram, there is only one copy of the code for that instantiation, just as there is only one copy of the code for the subprogram body. This is not considered that sharing, because no (sane) implementation would generate multiple copies of the code for a single subprogram body, and the instantiation is just part of that body. Randy.