TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Hans-Frieder Vogt <[log in to unmask]>
Reply To:
Hans-Frieder Vogt <[log in to unmask]>
Date:
Thu, 16 Jul 1998 12:00:26 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (88 lines)
On Jul 16, 10:24am, Alexander.Heim wrote:
> Subject: Problem with "and" - function (Array of Boolean)
> Hi Teamers,
>
>
> I'm posting the following problem for a friend of mine:
>
>
> > I have the following problem, when trying to implement a function "and".
> >
> >  package Some_Package is
> >    type Private_Type is private;
> >    function "And" (Left, Right: Private_Type) return Private_Type ;
> >  private
> >    type Private_Type is array (0 .. 1023) of Boolean;
> >  end Some_Package;
> >
> >
> > -- I want to implement Some_Package."And" using the predefined logical
> > -- operation "And" for any one-dimensional array type whose components
> > -- are of a boolean type.
> >  package body Some_Package is
> >    function "And" (Left, Right: Private_Type) return Private_Type   is
> >    begin
> >      return Left and Right;  -- ERROR: AND is here Some_Package."AND",
> >                              -- endless recursive
> >    end "and";
> >  end Some_Package;
> >
> > To fix the error in the implementation above, I need to qualify the
> > predefined
> > "And" operation:
> >
> >
> >  package body Some_Package is
> >    function "And" (Left, Right: Private_Type) return Private_Type is
> >    begin
> >      return Standard."And" (Left, Right);  -- ERROR: not possible
> >    end "and";
> >  end Some_Package;
> >
> > How is it possible to qualify the predefined logical operations to
> > distinguish between Some_Package."and" and the predefined "and"?
> >
> > Thanks in advance,
> >
> >
> > Juergen Hoyng,  RIO 62             |   email : [log in to unmask]
> > DASA/RI                            |   fax   : +49 421 539 4529
> > Postfach 286156                    |   voice : +49 421 539 5348
> > D-28361 Bremen                     |
> > Germany
>
>
>
>
> --
> Alexander Heim                       ___       Phone:  +49 421 539-5869
> Daimler-Benz Aerospace AG     ________|________  Fax:  +49 421 539-4424
> mailto:[log in to unmask]      0
>-- End of excerpt from Alexander.Heim

in both of your solutions, you assumed that the "and"-function is defined even
for the array type. But you didn't define that function like e.g.

package body Some_Package is
   function "And" (Left, Right: Private_Type) return Private_Type   is
      Return_Value : Private_Type;
   begin
      for I in Left'Range loop
         Return_Value (I) := Left (I) and Right (I);
      end loop;
      return Return_Value;
   end "and";
end Some_Package;


Hans-Frieder


--
--
Hans-Frieder Vogt                 e-mail: [log in to unmask]
Institut f"ur Luftfahrtantriebe   tel   : +49 (711) 685-3522
Universit"at Stuttgart
Pfaffenwaldring 6
D-70569 Stuttgart, Germany

ATOM RSS1 RSS2