From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f9cd205deb0d77f2 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: How can I qualify the predefined logical operations Date: 1998/07/16 Message-ID: #1/1 X-Deja-AN: 372034889 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <6okcnl$n93$1@nnrp1.dejanews.com> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-07-16T00:00:00+00:00 List-Id: hoyngj@my-dejanews.com wrote: : 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: The predefine "and" is declared at the point of the array type definition, i.e. immediately inside "Some_Package." However, you have a user-defined "and" with the same profile, so the predefined "and" is hidden by the user-defined one. : package body Some_Package is : function "And" (Left, Right: Private_Type) return Private_Type is : begin : return Standard."And" (Left, Right); -- ERROR: not possible This should not work (though it may work in some versions of GNAT), because the predefined "and" is *not* declared in package Standard. : 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"? You can't if they are both defined in the same scope. Here is a fix for your problem, involving converting to another array type whose "and" has a different profile from the user-defined one: function "and" (Left, Right : Private_Type) return Private_Type is type Local_Array is array(0..1023) of Boolean; -- "and" for Local_Array implicitly declared here begin return Private_Type(Local_Array(Left) and Local_Array(Right)); end "and"; : Thanks in advance : -- : Juergen Hoyng, RIO 62 | email : Juergen.Hoyng@ri.dasa.de : DASA/RI | fax : +49 421 539 4529 : Postfach 286156 | voice : +49 421 539 5348 : D-28361 Bremen | Germany -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA