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,f93e461e8491e322 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!a75g2000cwd.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Limited_Controlled, orthogonality and related issues Date: 19 Jan 2007 08:46:47 -0800 Organization: http://groups.google.com Message-ID: <1169225207.629809.167650@a75g2000cwd.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1169225214 27933 127.0.0.1 (19 Jan 2007 16:46:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 19 Jan 2007 16:46:54 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: a75g2000cwd.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:8335 Date: 2007-01-19T08:46:47-08:00 List-Id: Randy Brukardt wrote: > "Maciej Sobczak" wrote in message > news:eoned5$663$1@cernne03.cern.ch... > ... > > In conclusion, my decision to make T and S controlled appeared to not be > > orthogonal to the rest of the package. > > > > What are your thoughts about this? > > It's dubious to have two abstractions in the same package. It's a nice > simplification compared to other languages, but it's usually better to have > fewer types in one package rather than more. If T and S were in different > packages, this problem wouldn't happen. Note that one of the packages could > be nested or a child, and that would still have the visibility on the > private part. > > Something like: > > package Root is > type S is limited private; > ... > end Root; > > package Root.Child is > type T is limited private; > procedure Do_Something (A : T, B : S); > ... > end Root.Child; Yep, I hadn't thought of that. And if you use nested inside of child packages, you could do something like this: package Root is type S is limited private; package Inner is type T is limited private; end Inner; subtype T is Inner.T; procedure Do_Something (A : T; B : S); ... Now Do_Something isn't a primitive operator on T so there's no 3.9.2 error. Whether this is "appropriate" or not, I can't tell without knowing more about the exact types and operations involved. For the examples I can think of that I've worked with, S might be some sort of container type, T might be an iterator to help search through selected objects in S, and Do_Something might be a routine that returns successive elements of S that meet some criteria. In a case like that, Do_Something probably "belongs" inside the Inner package. But there are probably other cases where you would prefer to have Do_Something outside the Inner package. It's hard to say without knowing any details. But the point is, you can use a construct like this to avoid the "multiple dispatch" error, and this solution will still let you implement S and T any way you want in the private part---as opposed to making S and T part of the same package which prevents you from implementing both of them as tagged types. -- Adam