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,5c89acd494ea9116 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!news2.arglkargh.de!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 05 Sep 2007 23:38:34 +0200 From: Georg Bauhaus Organization: # User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Self pointer in limited record References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <9fy1xoukz1e3$.h574sqmiauri$.dlg@40tude.net> <46d968ee$0$30368$9b4e6d93@newsspool4.arcor-online.net> <137iu0lr82dtb$.wqy3zjz2vr9q.dlg@40tude.net> <46d972e8$0$30384$9b4e6d93@newsspool4.arcor-online.net> <1alyfwaig93sk$.99oy269uon$.dlg@40tude.net> <46d9c138$0$4531$9b4e6d93@newsspool3.arcor-online.net> <1rt8kdcrj6tf.1qgvycc6vh357$.dlg@40tude.net> <46db2bf4$0$7699$9b4e6d93@newsspool2.arcor-online.net> <1188816674.2630.25.camel@kartoffel.vocalweb.de> <9cdmw7k85sey.85sb2t1bjefy$.dlg@40tude.net> <1mbajw59c3eir.jyl8bdp6qvj8.dlg@40tude.net> <1188850449.2630.60.camel@kartoffel.vocalweb.de> <1aza6nzawgcnm.sf76q4dvzw4n$.dlg@40tude.net> <46de8897$0$16115$9b4e6d93@newsspool1.arcor-online.net> <15hzyyy3soem0.12hn79bwy27zt$.dlg@40tude.net> <1189017071.2630.246.camel@kartoffel.vocalweb.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <46df20aa$0$30370$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Date: 05 Sep 2007 23:33:31 CEST NNTP-Posting-Host: 37e7190c.newsspool4.arcor-online.net X-Trace: DXC=oU`Y3XbPbTm;iVb[J9ZZP`4IUKUR_5iA:ho7QcPOVc=HST=HBK_ofn=R0T\2e81l X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:1764 Date: 2007-09-05T23:33:31+02:00 List-Id: Dmitry A. Kazakov wrote: [snip all kinds of buzz words :-] >>> The point was "to have one instance" and "to be a FSM" are unrelated. >> There is a point of view from which the concept "to have one instance" >> and "to be a FSM" are unrelated. When writing an Ada program, you may >> have a point of view from which the concept "to have one instance" and >> "to be a FSM" coincide on a suitable conceptual level. It is the level >> on which an abstract state machine package is explained. > > Can I take a protected object or a task to implement either? You can take a package and implement either. > (I have no respect to singletons. They might have some sacral meaning for > some OO proponents, but that was always beyond my understanding.) They can avoid surprises and nasty issues because they enforce body visibility of data objects. Example: package S is type T is limited private; procedure op(x: in out T); private type T is limited record null; end record; end S; package body S is separate; -- ... a different programmer has a clever idea -- ... and adds another ad hoc procedure for -- ... debugging porposes procedure bar(x: S.T) is begin raise Program_Error; end bar; use S; item: T; begin bar(item); end; This is of course an artificial example. However, it serves to demonstrate a few effects. Once the object type T is visible outside the package (being declared in the public part of S), objects can be declared outside of S. Adding a subprogram like Bar will in a sense break grouping (where to look for bar which takes a T). If the author of S had intended an upper bound on instances of T, say one instance, then enforcing this limit will require more work. These issues go away with a simple abstract state machine style package.