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 Path: g2news1.google.com!postnews.google.com!q28g2000prb.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Limited use for limited with? Date: Tue, 28 Sep 2010 09:55:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2d380627-480e-4093-9a0f-a88beb70b189@q28g2000prb.googlegroups.com> References: <853314bc-0f79-435f-86a5-d7bcdd610731@c10g2000yqh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1285692947 17949 127.0.0.1 (28 Sep 2010 16:55:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 28 Sep 2010 16:55:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q28g2000prb.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:14296 Date: 2010-09-28T09:55:47-07:00 List-Id: On Sep 28, 12:37=A0am, 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 > > =A0 =A0type Object is interface; > =A0 =A0type Object_Access is access all Object'Class; > > =A0 =A0procedure 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 > > =A0 =A0 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: > > =A0 =A0 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. I'd recommend that you look at the example in the AI (AI95-217-6): http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-50217.txt and in particular the !example section. The example there shows two packages that depend on each other, using "limited with", but neither package declares an access type that is an access to a type in the same package. Instead, the Employees package declares a named access type whose designated type is in the Departments package; and the anonymous access types in both packages all refer to types in the other package. So the code that you find "uncomfortable" really *was* the way it was supposed to work, I think. I can understand that this solution may not have given you a way to express things the way you might have preferred. But doing things "perfectly" was, I believe, unfeasible. If you look at the ! discussion part of this AI, you'll realize how much effort the ARG put into trying to come up with a solution that would provide a reasonable way to solve a real problem while doing so in a way that could be implemented feasibly by compilers, and in a way so that precise language rules could be written and that problems that could arise from using different combinations of features were addressed. (Note: I am not an ARG member and was not part of this effort.) And then you have to multiply all that effort by seven, because "limited with" was just one of *seven* different proposed solutions to the mutual dependence problem, and all of them received extensive consideration. So it really rubs me the wrong way to see comments---not from you, but from someone else---such as "Ada2012 should relax rules to make limited with more useful." Perhaps it's because I'm reaching the Grumpy-Old-Fart-In-Training phase of my life. But given the amount of work the ARG put into this over a number of years, can't we at least assume that they did the best they could to make it as useful as they could, and that whatever rules are there that you don't like are there for a very good reason? Jeesh, now I sound like I'm talking to my teenager. Definitely headed for G.O.F. at full speed. I'm certainly not opposed to people wanting changes in the language (although it's too late for Ada 2012); but in this case, I'd recommend that if anyone wants to see this change, they should read the discussions in all the AI95-217 options (AI95-217-1 through 7) to make sure they understand all the issues, and then propose something specific. OK, I'm done ranting. For now. -- Adam