comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Parameterless generic instance in place of opaque type instance
Date: Sun, 28 Jul 2013 09:02:22 +0200
Date: 2013-07-28T09:02:22+02:00	[thread overview]
Message-ID: <op.w0w658dmule2fv@cardamome> (raw)
In-Reply-To: op.w0w5zaxpule2fv@cardamome

Le Sun, 28 Jul 2013 08:36:36 +0200, Yannick Duchêne (Hibou57)  
<yannick_duchene@yahoo.fr> a écrit:
> The Ada 95 Q&S Guide mention this pattern, and seems to have no more to  
> say about it, not more than what is obvious:
> http://www.adaic.org/resources/add_content/docs/95style/html/sec_8/8-3-5.html
> They call this pattern, “Generic Abstract Data Object”.

An idea, and there may have missed another interesting variation,  
something with mixed properties from a GADO and an ADT.

Say a GADO still defines an ADT, with an unknown discriminant, so that it  
cannot be instantiated without initialization. What the private declares,  
is just an access type to a deferred type (defined in the body). The body  
defines an instance of the type it fully defines. The package offers a  
single function returning an (opaque) access to this unique and  
per‑paquage instance, instance. The function could be named  
`Instance_Reference`, to clearly show it's always the same behind, however  
a new distinct one per generic instance (not strictly a singleton, a  
per‑package singleton).

This would provide some of the benefit of an ADT and some of a GADO,  
together. The same as an ADT regarding the ability to pass it to a  
sub‑program, while avoiding the heap allocation (which I surely don't  
want) otherwise required with an access to a deferred type (or else an  
allocation in a static pool, … not so nice for many reasons) and avoiding  
to pollute the private part of the package (I don't enjoy when the private  
part monopolizes 85% of a package's text).

This could be named, say “Generic Abstract Singleton Data Type”, or  
something like that :-D

What's you feeling on that variation?

-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University

  reply	other threads:[~2013-07-28  7:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-28  5:49 Parameterless generic instance in place of opaque type instance Yannick Duchêne (Hibou57)
2013-07-28  6:36 ` Yannick Duchêne (Hibou57)
2013-07-28  7:02   ` Yannick Duchêne (Hibou57) [this message]
2013-07-28  7:26     ` Yannick Duchêne (Hibou57)
2013-07-28  7:30 ` J-P. Rosen
2013-07-28  8:24   ` Yannick Duchêne (Hibou57)
2013-07-28 18:08     ` Shark8
2013-07-28 19:47       ` Yannick Duchêne (Hibou57)
2013-07-28 20:58         ` Shark8
2013-07-28 22:27           ` Yannick Duchêne (Hibou57)
2013-07-28 21:15         ` J-P. Rosen
2013-07-28 22:23           ` Shark8
2013-07-28 14:52 ` Robert A Duff
replies disabled

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