comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: beginner ada generic fonction
Date: 25 Mar 2002 06:05:36 +0000
Date: 2002-03-25T06:05:36+00:00	[thread overview]
Message-ID: <x7vr8m9ji6n.fsf@smaug.pushface.org> (raw)
In-Reply-To: 8235efb6.0203240931.182d6f19@posting.google.com

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 ...



  reply	other threads:[~2002-03-25  6:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-23  1:37 beginner ada generic fonction annabelle
2002-03-23  3:29 ` Steve Doiel
2002-03-24  2:55   ` annabelle
2002-03-24  3:10   ` annabelle
2002-03-24  3:51     ` Steve Doiel
2002-03-24 17:31       ` annabelle
2002-03-25  6:05         ` Simon Wright [this message]
2002-03-24 20:37       ` annabelle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox