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,c08a7609345f4e5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Limited use for limited with? Followup-To: comp.lang.ada Date: Tue, 28 Sep 2010 11:04:41 +0200 Organization: A noiseless patient Spider Message-ID: References: <853314bc-0f79-435f-86a5-d7bcdd610731@c10g2000yqh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Tue, 28 Sep 2010 09:06:16 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="w8g++bW4v3KH0+SqtoCNSw"; logging-data="20989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LkNQqgNyiav4haLkIxD4E" User-Agent: KNode/4.4.5 Cancel-Lock: sha1:2FGNhtXl+G1Jd1BEtHJImKIVcO0= Xref: g2news1.google.com comp.lang.ada:14286 Date: 2010-09-28T11:04:41+02:00 List-Id: Maciej Sobczak wrote: > I have found a problem with the intended application of limited with. > > Consider a package specifying some object-oriented construct: > > package Objects is > > type Object is interface; > type Object_Access is access all Object'Class; > > procedure Do_Something (X : in out Object) is abstract; > > end Objects; > > In such cases I routinely define the XYZ_Access type and later use it > wherever pointers to class-wide XYZ are needed. > > Now consider a package that uses the above in a limited way (pun > intended), where only pointers to class-wide type are needed: > > with Objects; > package Object_Users is > > procedure Use_Object (X : Objects.Object_Access); > > end Object_Users; > > The problem is that is some cases it would be more convenient (or just > more self-documenting from the design perspective) to do limited with > instead, but unfortunately this makes Object_Access unavailable. It is > OK to use anonymous access type, at least in some cases like here: > > procedure Use_Object (X : access Objects.Object'Class); > > but I find that uncomfortable - after all, the proper access type is > already defined for exactly this purpose. > > In such cases, where the design intent is pretty clear (pass around > references to Objects) I find that limited with does not really bring > the functionality that it is supposed to provide. In some more > involving cases I was forced to introduce additional and completely > artificial packages, where limited with would be a perfect fit. > > Any thoughts on this? Completely unhelpful on my part -- but my limited (ha) attempts at using "limited with" have been a failure. I'm no expert at OO or C++, like you, so I can't bring any expertise to the table. Something that can be of interest in this context is a discussion that happened not too long ago (half a year?) in some mailing list -- I thought it was the GAP one, but combing the topics I can't find it. People trying to do "proper" OO with the new Ada features was complaining about some unavoidable quirks. The discussion point was on the truth of "unavoidable". I'm failing at locating it, if it rings some bells for someone... Alex. > > -- > Maciej Sobczak * http://www.inspirel.com