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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b88383a5d9c51aa0 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news.glorb.com!news2.glorb.com!news.ecp.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Ada-Singleton-Why does it work like this? Date: Wed, 25 Mar 2009 12:17:57 +0100 Organization: Adalog Message-ID: References: <5a7a870c-40e2-4803-8753-0f9cfd2b800f@k2g2000yql.googlegroups.com> <13su65cm8b5ov$.1198qla32cc3i$.dlg@40tude.net> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1237974029 29285 195.25.228.57 (25 Mar 2009 09:40:29 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Wed, 25 Mar 2009 09:40:29 +0000 (UTC) User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:4296 Date: 2009-03-25T12:17:57+01:00 List-Id: patrick.gunia@googlemail.com a �crit : > [...] When you say > that Singleton isn�t necessary in Ada this might come from the fact > that it can�t be implemented as in other languages, though using such > a construct might increase readability of the code. I think there is a contradiction between "class" and "singleton". The term "class" is used, because it includes a set of objects that are equivalent for some point of view, i.e. a mathematical equivalence class. Now, if the class gathers only one object, the equivalence relationship does not make much sense... In some cases, you need a stand-alone object. Fine, but you don't need to define a class for that. Note that Ada allows you to define singleton arrays, tasks, and protected objects without an explicit type to enforce that notion. Some languages do not allow you to define an object unless it belongs to a class; that's why you have to jump through complicated hoops to define those "singleton classes", i.e. structures that are made to hold many objects, but with appropriate design patterns to make sure there is only one. It is simply not necessary in Ada. Note that it /can/ be implemented like in other languages, and I don't think it would be more complicated - just that the (unnecessary in the Ada case) complication shines more brightly. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr