comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: Why forbid local generic instantiations?
Date: Sat, 26 Jan 2019 12:11:12 +0100
Date: 2019-01-26T12:11:12+01:00	[thread overview]
Message-ID: <q2hf8h$q5b$1@dont-email.me> (raw)
In-Reply-To: <100ce3ee-71f7-46c7-a24c-dc9c0d280c4f@googlegroups.com>

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

  parent reply	other threads:[~2019-01-26 11:11 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
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. [this message]
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