comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generics vs. O-O?
Date: Fri, 2 Aug 2013 21:08:26 +0200
Date: 2013-08-02T21:08:26+02:00	[thread overview]
Message-ID: <qda7kp9p6ghz$.rq7cje5kx6f6$.dlg@40tude.net> (raw)
In-Reply-To: e6ea7bc6-0f16-4477-b383-e8bf8863b8da@googlegroups.com

On Fri, 2 Aug 2013 11:06:33 -0700 (PDT), Alan Jump wrote:

> On Friday, August 2, 2013 10:51:03 AM UTC-7, Dmitry A. Kazakov wrote:
>> Reasons to deploy this pattern in Ada are questionable at best.
>> Ada offers support of singletons where appropriate. Here is the list, maybe
>> incomplete:
>> 1. Anonymous arrays are singletons
>> 2. Procedures and functions are singletons
>> 3. Protected objects are singletons
>> 4. Tasks objects are singletons
> 
> You are stipulating that procedures, functions, protected objects and task
> objects are singletons, but at the same time, stating there are only
> questionable reasons to make use of them?

Not them, but the singleton pattern. You don't need any pattern to make a
procedure singleton. You just define it and here you are, it is a
singleton. Let me elaborate a bit:

1. Anonymous arrays are declared as:

   A : array (1..10) of Character; -- This is a singleton

Compare:

   type Multitude is array (1..10) of Character; -- Not a singleton
   A : Multitude; -- One instance
   B : Multitude; -- Another instance

2. Procedures and functions:

   procedure Foo (I : Integer); -- This a singleton

Ada does not have named procedural types. Thus subroutines are always
singletons.

3. protected Singleton is ...; -- This is a singleton

Compare

   protected type Multitude is ..;
   A : Multitude;
   B : Multitude;

4. task Singleton is ...; -- This is a singleton

Compare;

   task type Multitude is ...;
   A : Multitude;
   B : Multitude;

> Semantically, you have just
> eliminated the core raison d'etre for the existence of Ada as a
> language...specifically, strong typing.

Why? The type of a procedure is not weak. Strong typing is about relation
between objects and types, such that an object has a type (plus some other
requirements). It does not imply that a type has an object (singleton).
Normally the latter is considered a design artifact. Unless trivial cases
like I listed above, more elaborated abstract types are better designed not
to be singletons. Relying on single instance is fragile design.
Notwithstanding that sometimes it is what you need.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2013-08-02 19:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 14:45 Generics vs. O-O? Eryndlia Mavourneen
2013-08-01 19:24 ` Dmitry A. Kazakov
2013-08-01 19:52   ` Eryndlia Mavourneen
2013-08-01 20:14     ` sbelmont700
2013-08-01 23:35       ` Yannick Duchêne (Hibou57)
2013-08-01 20:10   ` optikos
2013-08-01 20:26     ` Dmitry A. Kazakov
2013-08-01 20:35     ` Jeffrey Carter
2013-08-01 21:22     ` Bill Findlay
2013-08-01 23:38     ` Yannick Duchêne (Hibou57)
2013-08-01 22:20   ` Georg Bauhaus
2013-08-02  8:11     ` Dmitry A. Kazakov
2013-08-02  9:50       ` Georg Bauhaus
2013-08-02 14:09         ` Dmitry A. Kazakov
2013-08-02 15:08           ` Shark8
2013-08-02 15:36             ` Alan Jump
2013-08-02 17:00               ` Jeffrey Carter
2013-08-02 17:51               ` Dmitry A. Kazakov
2013-08-02 18:06                 ` Alan Jump
2013-08-02 19:08                   ` Dmitry A. Kazakov [this message]
2013-08-02 16:15             ` Dmitry A. Kazakov
2013-08-03  0:04       ` Yannick Duchêne (Hibou57)
2013-08-03  7:35         ` Georg Bauhaus
2013-08-03  8:57           ` Dmitry A. Kazakov
replies disabled

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