Subject: | |
From: | |
Reply To: | |
Date: | Thu, 16 Jul 1998 11:09:20 +0200 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Here is one solution to this problem :
package Some_Package is
type Private_Type is private;
function "And" (Left, Right: Private_Type) return Private_Type;
private
type Array_Type is array (0 .. 1023) of Boolean;
type Private_Type is new Array_Type;
end Some_Package;
package body Some_Package is
function "And" (Left, Right: Private_Type) return Private_Type is
begin
return Private_Type (Array_Type (Left) and Array_Type (Right));
end "and";
end Some_Package;
Pascal.
--|------------------------------------------------------------
--| Pascal Obry Team-Ada Member |
--| |
--| EDF-DER-IPN-SID- T T I |
--| Intranet: http://cln49ae |
--| Bureau N-023 e-mail: [log in to unmask] |
--| 1 Av Général de Gaulle voice : +33-1-47.65.50.91 |
--| 92141 Clamart CEDEX fax : +33-1-47.65.50.07 |
--| FRANCE |
--|------------------------------------------------------------
--|
--| http://ourworld.compuserve.com/homepages/pascal_obry
--|
--| "The best way to travel is by means of imagination"
> -----Message d'origine-----
> De: Team Ada: Ada Advocacy Issues (83 & 95)
> [mailto:[log in to unmask]]De
> la part de Alexander.Heim
> Date: jeudi 16 juillet 1998 10:25
> À: [log in to unmask]
> Objet: 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
>
|
|
|