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,31a8e118c303e8b3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-25 12:13:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!pogner.demon.co.uk!zap!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: beginner ada generic fonction Date: 25 Mar 2002 06:05:36 +0000 Organization: Pushface Message-ID: References: <8235efb6.0203221737.44abefff@posting.google.com> <3ESm8.101615$q2.10433@sccrnsc01> <8235efb6.0203231910.65856099@posting.google.com> <8235efb6.0203240931.182d6f19@posting.google.com> NNTP-Posting-Host: localhost X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 X-Trace: news.demon.co.uk 1017087165 nnrp-12:17972 NO-IDENT pogner.demon.co.uk:158.152.70.98 X-Complaints-To: abuse@demon.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Date: 25 Mar 2002 06:05:36 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:21656 Date: 2002-03-25T06:05:36+00:00 List-Id: ametayer98@hotmail.com (annabelle) writes: > The thing is, I was given the following spec and I cant change it. > I've GOT to use it as it is. > > I can make the "LaCle" function to work but now I have trouble with > the "<" function... > > I would love to have an example of how I call this "<" in my ADB file > and how do I define this function in my ADA project... > > I know I am a pain in the neck !!! I have great difficulty with the > concept but I know I CAN understand eventually !!! > > GENERIC > TYPE Type_Element IS Private; -- Type > de l'enregistrement a gerer > TYPE Type_Cle IS Private; -- Type > de la cle de l'enregistrement > WITH Function LaCle (mon_item : Type_Element) Return Type_Cle; -- > Fonction qui retourne la valeur de la cle > WITH Function "<" (Gauche,Droite : Type_Cle) Return Boolean; -- > Importation de l'operateur < pour comparer des cles Removing the comments so that it fits on a line, GENERIC TYPE Type_Element IS Private; TYPE Type_Cle IS Private; WITH Function LaCle (mon_item : Type_Element) Return Type_Cle; WITH Function "<" (Gauche,Droite : Type_Cle) Return Boolean; there is something missing, namely what it is that is is to be generic. The next line must start with PACKAGE, PROCEDURE or FUNCTION. The idea is that *you* supply a function LaCle and a function "<" which work as indicated with a Type_Cle (whatever that is), and then the *instantiation of the generic* calls the functions to do what it needs to do ...