comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Why forbid local generic instantiations?
Date: Fri, 25 Jan 2019 17:36:33 +0100
Date: 2019-01-25T17:36:33+01:00	[thread overview]
Message-ID: <q2fdui$9vn$1@dont-email.me> (raw)
In-Reply-To: <100ce3ee-71f7-46c7-a24c-dc9c0d280c4f@googlegroups.com>

On 1/25/19 10:43 AM, 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.

It isn't bad practice. Mostly such rules are premature optimization. Are there 
rules against regular pkgs in such places? There's no difference.

It makes perfect sense for things to be declared in the smallest scope in which 
they're needed. This is true of anything, not just pkgs.

A pkg in a subprogram is elaborated every time the subprogram is called. If the 
elaboration of a specific pkg is expensive and timing requirements are tight, it 
might make sense to move that pkg to a larger scope. But a general rule against 
them for "efficiency" doesn't make sense. Limiting it to pkgs that are generic 
instantiations makes less sense.

Perhaps such people don't know that instantiation takes place during compilation 
and has no run-time impact.

As a 1st-order approximation, anything the "C++ Community" does should be avoided.

-- 
Jeff Carter
"I was hobbling along, minding my own business, all of a
sudden, up he comes, cures me! One minute I'm a leper with
a trade, next minute my livelihood's gone! Not so much as a
'by your leave!' You're cured, mate. Bloody do-gooder!"
Monty Python's Life of Brian
76

  reply	other threads:[~2019-01-25 16:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25  9:43 Why forbid local generic instantiations? joakimds
2019-01-25 16:36 ` Jeffrey R. Carter [this message]
2019-01-25 21:23   ` Randy Brukardt
2019-01-26  9:56     ` Jeffrey R. Carter
2019-01-29  7:35       ` Randy Brukardt
2019-01-25 21:34 ` Randy Brukardt
2019-01-26 11:11 ` G.B.
2019-01-28 11:43   ` joakimds
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox