From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Generics vs. O-O? Date: Fri, 2 Aug 2013 21:08:26 +0200 Organization: cbb software GmbH Message-ID: References: <6238c325-79c5-4537-ba55-2800110dc6df@googlegroups.com> <1wugpqyea6s39$.e2e8eshup5wn$.dlg@40tude.net> <51fadf40$0$6557$9b4e6d93@newsspool4.arcor-online.net> <15qso6tlt3uf1.h45wqc019b00$.dlg@40tude.net> <51fb80d8$0$6561$9b4e6d93@newsspool4.arcor-online.net> <1so729qnkrrj2.ztrxvmlw6cb7.dlg@40tude.net> <8bef1dc4-547b-478e-b81a-09077212f821@googlegroups.com> <16kwiwxqxuhu4$.y37yztzjskfv$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: q/ev1P9zCVSwu+vpMGX5Tw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 3487 Xref: number.nntp.dca.giganews.com comp.lang.ada:182824 Date: 2013-08-02T21:08:26+02:00 List-Id: 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