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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Why forbid local generic instantiations? Date: Sat, 26 Jan 2019 12:11:12 +0100 Organization: A noiseless patient Spider Message-ID: References: <100ce3ee-71f7-46c7-a24c-dc9c0d280c4f@googlegroups.com> Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 26 Jan 2019 11:11:13 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="d833269b972f19620c14587b50f51e12"; logging-data="26795"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vBlx+2kW1anOh1UbPuv3oZtHLvsSnPEo=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 Cancel-Lock: sha1:temOJxcqH67FNbUU3GHWFkwZeQo= In-Reply-To: <100ce3ee-71f7-46c7-a24c-dc9c0d280c4f@googlegroups.com> Content-Language: de-DE Xref: reader01.eternal-september.org comp.lang.ada:55379 Date: 2019-01-26T12:11:12+01:00 List-Id: On 25.01.19 10:43, joakimds@kth.se wrote: > > Why is it considered bad practise to use local generic instantiations? Within the C++ Community, limiting the use of templates doesn't seem an issue. On the contrary, going all in with template metaprogramming is the norm. Note that C++ templates are instantiated at compile time, whereas Ada generics may be instantiated at runtime. Ada instances may depend on runtime values. Locally instantiating a generic may be considered less suitable if you prefer "flattening" all programs: no hierarchies, no nesting at all. Compiler-savvy people may have a preference for flat, too, I think, if the result is "better" object code. Or, easier compilation, provided that instantiation at library level reduces the number of dependencies in scope. Nesting introduces more global entities as a consequence. There are trade-offs, I think. Spaghetti is the preferred dish when everything should be "flat": Because if nothing is local, the connections of objects or instances, such as calls, need to be explicitly naming all parties, OTOH, when declarations are directly visible through nesting, the connections to entities are implicit. Nesting may offer features connected to local scope, such as implicit life cycle control; same trade-offs, maybe. -- "HOTDOGS ARE NOT BOOKMARKS" Springfield Elementary teaching staff