From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Instantiations of a generic with often encountered arguments
Date: Sun, 26 Nov 2017 09:52:35 +0100
Date: 2017-11-26T09:52:35+01:00 [thread overview]
Message-ID: <ovdvck$2r4$1@gioia.aioe.org> (raw)
In-Reply-To: ovd0dt$hmi$1@gioia.aioe.org
On 2017-11-26 01:04, Victor Porton wrote:
> Is it a good practice to declare "centralized" (that is in the same package
> as a generic packages is defined in, or in a child unit) instantiations of a
> generic package with common (that is often encountered, such as Integer,
> String, etc.) generic parameters?
Yes, Ada library does so for standard types.
Sometimes a set of related generic packages is instantiated in a third
package which is then used. E.g. you have a generic vector, matrix,
solver defined over the same type.
> In C++ this is not a problem, because there a template is instantiated
> whenever one needs it.
Because in C++ templates are 100% macros, whereas in Ada generic
instances can be shared, theoretically at least, and should be treated
as real packages.
Then C++ templates have structrual matching, all instances/expansions
with same parameters are same. It is no matter where you would expand a
macro. Ada uses nominal matching of generic instances and they can be
scoped.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2017-11-26 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-26 0:04 Instantiations of a generic with often encountered arguments Victor Porton
2017-11-26 2:24 ` gautier_niouzes
2017-11-26 8:52 ` Dmitry A. Kazakov [this message]
2017-11-27 2:02 ` Victor Porton
2017-11-27 8:00 ` Simon Wright
2017-11-27 8:41 ` Dmitry A. Kazakov
2017-11-27 16:05 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox