comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Problem with anonymous arrays
Date: Sun, 25 Apr 2004 18:01:48 +0000 (UTC)
Date: 2004-04-25T18:01:48+00:00	[thread overview]
Message-ID: <slrnc8nv8c.1ku.lutz@belenus.iks-jena.de> (raw)
In-Reply-To: pan.2004.04.25.08.10.33.660305@wanadoo.fr

* Delf wrote:
> entry EnterGiratoire (I: Integer) when NbCarsOnRP = 0 or (NbCarsOnRP > 0
> and NbCarsOnRP < MAXCARS and I = WhoCanPass) is
>
> But gnatmake says: Giratoire.adb:35:109: "I" is undefined

I is defined AFTER the guard is passed.
If you like to provide parameters TO the guard you have to use entry families:

type Family is range 1 .. 16;
protected type XXX is
  entry EnterGiratoire(Family)(other: Parameter);
end XXX;

protected body XXX is
  entry EnterGiratoire(for I in Family)(other : Parameter)
   when ... I = WhoCanPass is
  begin
     ...
  end EnterGiratoire;
end XXX;

Please note, that entry families can be instantiated as separate procedures
for each possible value of the family parameter. So the usable range of
values is limited. GNAT allows the whole Integer range, but fails miserably
in instantiating with Storage_Error.



      parent reply	other threads:[~2004-04-25 18:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-24 22:46 Problem with anonymous arrays Delf
2004-04-24 23:26 ` Lutz Donnerhacke
2004-04-25  0:29   ` Delf
2004-04-25  8:10 ` Delf
2004-04-25 17:58   ` Lutz Donnerhacke
2004-04-25 18:01   ` Lutz Donnerhacke [this message]
replies disabled

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