comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: What is the difference?
Date: Mon, 12 Aug 2019 06:44:41 -0700 (PDT)
Date: 2019-08-12T06:44:41-07:00	[thread overview]
Message-ID: <c30100dc-0ff0-4b25-9280-26ef77f1c42e@googlegroups.com> (raw)
In-Reply-To: <50918b3d-cc75-4375-8735-8c007287f357@googlegroups.com>

> What is here the meaning of: is <>?

That is a default; if there is a matching subprogram (name, parameters) then it can use that without being specified. Example:

Generic
  Type Element(<>) is private;
  Unity : Element;
  with Function "*"(Left, Right : Element) return Element is <>;
Function Generic_Exponent( Left : Element; Right : Natural ) return Element;
--...
Function Generic_Exponent( Left : Element; Right : Natural ) return Element is
(case Right is
  when 0 => Unity,
  when 1 => Left,
  when 2 => Left * Left,
  when others =>
   (if Right mod 2 = 0 
    then  (Left ** (Right/2) ** 2
    else ((Left ** (Right/2) ** 2) * Left
   )
);

Now you can say something like
Procedure Test is
  Type X is 1..8;
  Function Exp is new Generic_Exponent(X, 1, others => <>);
  Function "**"(Left : X; Right : Natural) Return X renames Exp;
Begin
  --Testing procedures
End Test;

      parent reply	other threads:[~2019-08-12 13:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10 13:59 What is the difference? Gilbert Gosseyn
2019-08-10 15:24 ` Jeffrey R. Carter
2019-08-10 16:04   ` Gilbert Gosseyn
2019-08-12 13:44 ` Shark8 [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