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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8ffd9ca0013db6a7 X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: Redefined "=" = generic disaster? Date: 2000/10/21 Message-ID: <39F1C092.87D4135E@acm.org>#1/1 X-Deja-AN: 684175927 Content-Transfer-Encoding: 7bit References: <39F13ED9.1EE@li.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 972144801 158.252.122.148 (Sat, 21 Oct 2000 09:13:21 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Sat, 21 Oct 2000 09:13:21 PDT Newsgroups: comp.lang.ada Date: 2000-10-21T00:00:00+00:00 List-Id: Vincent Marciante wrote: > generic > type Something is private; > package Ada_83_Abstract_Data_Type is > type ADT is private; > ... > function Is_Equal (L,R: ADT) return Boolean; > end; > package body Ada_83_Abstract_Data_Type is > ... > function Is_Equal (L,R: ADT) return Boolean; > begin > return L = R; > end; > end; This is not valid Ada 83. Assuming we add a private part to the spec and replace the ";" after "Boolean" with " is" in the body, you are invoking the predefined "=" on the local type ADT, not the generic formal type Something. Since we don't know the full definition of ADT, we don't know what this has to do with "=" for Something. If ADT is a composite type with one or more components of type Something, then "=" for ADT is defined (at least partly) in terms of the predefined "=" for Something. > BTW, I not interested in arguments that the old Ada 83 code was actually > incorrect when it first written. I am interested in finding out wats to > update it so that it works as one would expect ;) in Ada 95. Any generic that uses "=" for a generic formal type should explicitly import "=" for the type: generic -- Some_Package type T is private; with function "=" (Left : T; Right : T) return Boolean is <>; package Some_Package is ... > think of now is ethier add > > function "=" (L,R: Private_Type) return Boolean is "="; The construct is "=" on a generic formal function (note that you need "with" before "function") refers to a function named "=" that is visible when the generic is compiled. Such a function is unlikely to exist for a generic formal private type. To refer to a function "=" that is visible when the generic is instantiated, which is probably what you wanted, use is <> instead. > P.S. Wow its late, I hope (all/most;) of the above makes sense! Possibly. -- Jeff Carter "I waggle my private parts at your aunties." Monty Python & the Holy Grail