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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Successor Language Date: Sat, 30 Jun 2018 10:34:46 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5e86db65-84b9-4b5b-9aea-427a658b5ae7@googlegroups.com> <878t7u1cfm.fsf@nightsong.com> <776f3645-ed0c-4118-9b4d-21660e3bba4b@googlegroups.com> <87602fbu2g.fsf@nightsong.com> <87po0mziqt.fsf@nightsong.com> <87fu1izfgs.fsf@nightsong.com> NNTP-Posting-Host: 3CrKQyqWAJZHy6zYVP/kUg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:53470 Date: 2018-06-30T10:34:46+02:00 List-Id: On 2018-06-30 00:36, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:ph6aqs$1cj7$1@gioia.aioe.org... >> On 2018-06-29 22:17, Randy Brukardt wrote: >>> "Dmitry A. Kazakov" wrote in message >>> news:pgd1hq$ca2$1@gioia.aioe.org... >>> ... >>>> 4. No proper reuse. Generic bodies are no proper compilation units, you >>>> cannot have a shared library of generics. Therefore the only possible >>>> form >>>> of reuse is textual substitution and recompilation of the client code. >>> >>> Since Janus/Ada implements them exactly this way, this is demonstratably >>> false. The lack of reuse in some implementations (i.e. GNAT) is an >>> intended >>> implementation decision, not a language requirement. >> >> You must use some very special linker/loader then. Considering a generic >> package like: >> >> generic >> type T is private; >> with function Init return T; >> package P >> X : T := Init; >> end P; >> >> the linker must magically multiply the object X for each instance of the >> package P and call Init for each of them, none of which it may know in >> advance. > > You've forgotten the magic of a level of indirection. :-) Every generic > operation takes a (hidden) parameter that is a generic sharing block, and > that includes all of the package-level data for the generic, information > about the generic parameters, and more. The linker has nothing to do with > it. OK, but that means precisely that the things you pass this way are not shared! You can share only parts of a generic unit, not everything. > It's the sharing data and the level of indirection that it implies that > makes generic sharing run slower than a macro approach. Dispatch allows to formalize things being passed as a context of a call and binds these things to a type and an operation of. Same approach, but clean and well-defined. > 'twasn't my idea. I probably would have treated them the same, with more > contracts in the formal part. But that would be clearly harder to use, so > it's hard to be certain that it would be better. It surely would be easier > to implement (there's some 60 rules that have to be re-enforced in an > instantiation, all of which require special code in Janus/Ada. I see the > appeal of GNAT's approach, but then they have to be able to *not* enforce > those 60 rules in generic instance bodies. Doesn't sound a lot better. :-) It simply does not worth to invest limited resources into generics. That thing will never fly, IMO. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de