comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: Generics not overloadable
Date: Fri, 30 Nov 2001 22:38:04 -0000
Date: 2001-11-30T22:38:04+00:00	[thread overview]
Message-ID: <9u91u5$71h5k$2@ID-25716.news.dfncis.de> (raw)
In-Reply-To: fKvN7.1436$726.493581@news1.sttln1.wa.home.com

I think what Ian meant was that a generic unit can be a function, and some
functions are recursive. E.g.:

   generic
      type Number is range <>;
   function Factorial (N: in Number) return Number;

   function Factorial (N: in Number) return Number is
   begin
      if N < 0 then raise Constraint_Error; end if;
      if N < 2 then return 1; end if;
      return N * Factorial(N-1);
   end;

Here the last occurance of 'Factorial' is the use of the generic unit's name
as its current instance in order to make a recursive call upon itself.

--
Best wishes,
Nick Roberts






  reply	other threads:[~2001-11-30 22:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-28 21:10 Generics not overloadable Mark Lundquist
2001-11-28 21:29 ` Ted Dennison
2001-11-29  3:41   ` Robert Dewar
2001-11-29  5:49     ` R. Tim Coslet
2001-12-09 14:05     ` Mark Lundquist
2001-12-10 16:15       ` Stephen Leake
2001-11-29 10:41 ` Ian Wild
2001-11-29 19:10   ` Mark Lundquist
2001-11-30 22:38     ` Nick Roberts [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-11-28 17:44 Mark Lundquist
replies disabled

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