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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,189a28164788ed2e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-29 09:54:54 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: Using "with function" Date: Mon, 29 Oct 2001 12:58:03 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:15362 Date: 2001-10-29T12:58:03-05:00 List-Id: Actually, this is an interesting question because the generic formal type is nonlimited -- which means it already comes with a predefined equality operator. A rule of thumb for generics is that even for nonlimited types, it's still a good idea to import the equality operator explicitly. Also, in general, you should use default notation for generic formal subprograms, like this: generic type Element_Type is private; with function "=" (L, R : Elemenet_Type) return Boolean is <>; --say "is box" package GP is This simplifies the instantiation, because you don't have to specify the operation(s) explicitly. Another thing to think about is that if the equality operator is used only to implement a single operation (say, this is a container object, with its own equality operator), then you could defer implementation of the operation, by moving it to a child: generic type Element_Type is private; package GP is ... generic with function "=" (L, R : Element_Type) return Boolean is <>; function GP.Generic_Equality (L, R : Container_Type) return Boolean; Another question to ask is whether you need assignment of elements. If not, then you could declare the generic formal type as limited: generic type Element_Type is limited private; package GP is ... This would have the effect of also removing default equality (limited types don't have predefined equality). The idea is that for generic formals, you want to require as little from your client as possible. I call this (after Deitel) the "principle of least committment." Regards, Matt "Matt Raikes" wrote in message news:ab21b49a.0107200756.41292cf3@posting.google.com... > I ran across this in some code I was examining and I have no clue how > the with function part works or what its purpose is. > > generic > type Element_Type is private; > with function "="( Left, Right: Element_Type ) return Boolean; > > > please help