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,342467ecd9a142cf X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Which compiler is right ? Date: 1997/07/25 Message-ID: #1/1 X-Deja-AN: 258876440 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <33D718BA.1E9A@magic.fr> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-07-25T00:00:00+00:00 List-Id: Strategies (strategies@magic.fr) wrote: : Hello : Is the following code legal ? No. : I have two compilers with two different answers The one that rejects the program is correct. : generic : type Element_Type is limited private; : type Index_Type is (<>); : type Element_Array is array (Index_Type range <>) of Element_Type; : with function Equal (Left, Right : Element_Type) : return Boolean is "="; When you give a default for a function like this (is "="), it is looked up when the generic is compiled, as opposed to when it is instantiated. And there is no "=" visible that matches the given parameter profile. The only way to specify a default that is looked up when a generic is instantiated is to use "is <>", and then the name of the formal subprogram must match the name that you want looked up at the point of instantiation. Hence, you could do the following: with function "="(Left, Right : Element_Type) return Boolean is <>; Now when you instantiate this generic, if the actual parameter is omitted for this formal parameter, then the compiler will look for a directly visible "=" that matches the given profile. If you prefer to use the name "Equal" inside the generic, you could add a remame inside the generic body, such as: function Equal(Left, Right : Element_Type) return Boolean renames "="; By the way, I agree with the other responder that when you have a question like this, it sure makes it easier to help if you include the error messages produced by the compiler(s) with your question. : function Generic_Indice (Left : : Element_Type; Right : Element_Array) return : Index_Type; : -- : ------------------------------------------------------------------------ : -- Jerome HAGUET, Strategies, Rungis, France -- : -- Tel : (33 1 | 01) 41 73 04 80 ; Fax : (33 1 | 01) 41 73 04 99 -- : -- Internet : strategies@magic.fr ; Compuserve : 100747,2001 -- : ------------------------------------------------------------------------ -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA