comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Re: Instantiations of a generic with often encountered arguments
Date: Mon, 27 Nov 2017 04:02:20 +0200
Date: 2017-11-27T04:02:20+02:00	[thread overview]
Message-ID: <ovfrna$1hkd$1@gioia.aioe.org> (raw)
In-Reply-To: ovdvck$2r4$1@gioia.aioe.org

Dmitry A. Kazakov wrote:

> 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.

Where?!

> 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.

I received what seems two opposite opinions on my question.

Please state the reasons.

I am now in analysis-paralysis of whether to define instantiations for often 
encountered types in advance (globally) or immediately before use.

-- 
Victor Porton - http://portonvictor.org


  reply	other threads:[~2017-11-27  2:02 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
2017-11-27  2:02   ` Victor Porton [this message]
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