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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,189a28164788ed2e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-30 14:48:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "Steven Deller" Newsgroups: comp.lang.ada Subject: RE: Using "with function" Date: Tue, 30 Oct 2001 17:45:23 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1004482124 10821 137.194.161.2 (30 Oct 2001 22:48:44 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 30 Oct 2001 22:48:44 +0000 (UTC) To: Return-Path: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) Importance: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk X-Reply-To: List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:15441 Date: 2001-10-30T17:45:23-05:00 > -----Original Message----- > From: comp.lang.ada-admin@ada.eu.org > [mailto:comp.lang.ada-admin@ada.eu.org]On Behalf Of Mark Lundquist > Sent: Tuesday, October 30, 2001 12:50 PM > To: comp.lang.ada@ada.eu.org > Subject: Re: Using "with function" ... > This is one of the things about Ada generics that might be a little > counterintuitive until one gets the hang of it, don't you > think? A generic > formal type is like a type declaration to the generic body, > so words like > "limited" and "abstract" have their normal meaning to the body (and > technically, to the rest of the spec), which is that there are certain > things you're not allowed to do there -- e.g. assigning to > objects of a > limited type, creating an object of an abstract type, etc. > But for the > instantiator, it's the flip side, and these words mean that > the actual type > is not required to have the corresponding properties. Actually, it means *in all cases* that the actual type MUST have the corresponding type properties, and it MAY have additional properties. A non-abstract type has all the properties of an abstract type and then some. The reverse is not true, so an abstract type may *not* be an actual for a non-abstract formal. A non-limited type has all the properties of a limited type and then some. The reverse is not true, so a limited type may *not* be an actual for a non-limited formal. A non-tagged type does *not* have all the properties of a tagged type. The reverse it true, so a tagged type may be used as the actual for a non-tagged formal. A formal states what properties of a type the generic code may use and therefore, must be supplied in an instantiation. It makes sense to use the minimal set of type properties (and so state in the formal declaration), so the widest set of types may be used to instantiate the generic. > So the user of a > generic should read "limited" as "allowed to be limited" (but can be > limited); and while "tagged" indeed means "must be tagged", > "abstract" means > "is allowed to be abstract" (but can be non-abstract). ... "limited" as "must include properties of a limited type" ... "tagged" as "must include properties of a tagged type" ... "abstract" as "must include properties of an abstract type" > The same goes for unknown discriminants in the generic formal type. > > For maximum flexibility, the rules of thumb for formal > private types are: > > 1) Declare as limited, if possible. > 2) Declare with unknown discriminants, if possible > 3) For tagged formals, declare as abstract if possible The rule of thumb is use a formal with the least amount of properties possible. Use "private" if possible. Use "limited" if possible. Leave out "tagged" if possible. Leave out discriminants if possible. Use "abstract" if possible. With discriminants there is one quirk -- to allow an indefinite discriminated type to be used in an instantiation, the formal must have a discriminant part. That is necessary so within the generic, use of the type is able to "see" what the current discriminant is (to work with the type). This is really just a corollary to the principle that an actual must have the properties of the formal -- an indefinite discriminated type does not have all the "properties" of a non-discriminated type. Regards, Steve "Then, after a second or so, nothing continued to happen." Steven Deller Smooth Sailing LLC 410 757 6924 deller@smsail.com