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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: What is your opinion on Global Objects? Date: Sat, 22 Nov 2014 08:46:36 +0100 Organization: A noiseless patient Spider Message-ID: References: <1tz9u84opgdwc$.a7dpkorp05gp.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 22 Nov 2014 07:46:25 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2b3884a634d8f846e0712b4e3a92507a"; logging-data="10272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DTa6TGDK3Lh2z1PRuv/Ut" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <1tz9u84opgdwc$.a7dpkorp05gp.dlg@40tude.net> Cancel-Lock: sha1:N5OUfI11WJEou+Gk4/93rbuCXSU= Xref: news.eternal-september.org comp.lang.ada:23629 Date: 2014-11-22T08:46:36+01:00 List-Id: Le 21/11/2014 10:01, Dmitry A. Kazakov a écrit : > On Thu, 20 Nov 2014 22:35:16 +0100, J-P. Rosen wrote: > >>> 1. You are hardcoded to a particular implementation (i.e. no dispatching) >> Yes, it is more static, therefore safer and more easily provable. > > This is a bit contradictory. Proofs as such are always against some stated > things. That already presumes several instances. Some instances may > withstand the proof some don't. Thus the idea of proving an inherent > singleton looks somewhat dubious. Singleton is only in the usage not a > property. Not at all. Where we differ is that you are thinking in terms of classes first, then instances. You see the properties at class level, and then a singleton (a class with a single instance) makes little sense. I am thinking in terms of objects first. Objects have properties. If several objects share a common behaviour, then I group them into "equivalence classes", and the common properties of the objects become the properties of the class. If you think objects first, singletons make perfect sense. > And you forgot about reuse. A singleton implementation may use some other > types implementations or provide its implementation for reuse. You implicitely think of reuse by inheritance. I favor reuse by composition. > >>> 3. The majority of the program becomes impure Not really. If your problem requires a global state, then it is "impure". Whether you use global variables in a package or a global object gathering the data that you pass to subprograms does not change anything. >>> 5. Everything is compile-time constant (i.e. no creating or deleting things dynamically). >> I would regard this as a huge benefit - dynamicity has always been >> opposed to simplicity and provability. > > Huh, that reminds me of a relatively fresh discussion about termination of > a library-level task in Ada. A typical singleton, isn't it? Yet impossible > to terminate on application exit! ??? Select ... or terminate works perfectly well for library tasks. I do that all the time. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr