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 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!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Self pointer in limited record Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <1188578849.187422.280620@50g2000hsm.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> Date: Sat, 1 Sep 2007 18:03:00 +0200 Message-ID: <1alyfwaig93sk$.99oy269uon$.dlg@40tude.net> NNTP-Posting-Date: 01 Sep 2007 18:02:40 CEST NNTP-Posting-Host: ebb0b112.newsspool1.arcor-online.net X-Trace: DXC=P7C?06jLD;LlIh70@U6QABNDNcfSJ;bb[EIRnRBaCd On Sat, 01 Sep 2007 16:15:44 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: >> On Sat, 01 Sep 2007 15:33:09 +0200, Georg Bauhaus wrote: >> >>> (The true O-O programmer might suggest that we should simply >>> pass an additional object-as-module parameter to every >>> package subprogram... ) >> >> Yes, it is better to keep packages stateless. > > Though by using tagged objects for a module > and not a stateful package, you will dismiss a few > properties of packages that can be helpful when > modeling singleton modules: > > 1 - If there is just one object in the problem domain a > package is a perfect match and will be straight forward, safe, > and simple to implement. No need to worry about static and > dynamic scopes of module-objects passed around because > there is just this one named package for the problem > domain object. Yes, yes, but this is a different case. Dealing with singletons, I probably would use a [stateful] package instead of objects. Types presume multiple instances of. Singleton in OO breaks this concept. Ada offers a cleaner alternative. Why should we force it into a type? Let it be a package. I think the empiric rule could be: if a package is used to declare types, then it should have no mutable state. Otherwise it should not have type declarations. > 2 - Nesting packages is an option, a distinguishing feature > of Ada IMO; a package nested inside a subprogram is a > simple solution to the life cycle problem of module style > objects. Hmm, a subprogram has all properties of a package. So there is no obvious reason why nested package (except instances of generic packages, of course), might be useful there. BTW, I guess child and separate packages might probably replace nested packages. Excluding generics, I mean. Maybe if there were no generic packages we could drop them altogether. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de