comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Newbie Generic Reg Exp Pattern Matching Question
Date: 4 Oct 94 11:29:39
Date: 1994-10-04T11:29:39+00:00	[thread overview]
Message-ID: <EACHUS.94Oct4112939@spectre.mitre.org> (raw)
In-Reply-To: 944166@edna.swin.edu.au's message of 3 Oct 1994 14:54:52 GMT

In article <36p5vsINNcjt@edna.cc.swin.edu.au> 944166@edna.swin.edu.au (Jimmy Fang) writes:

	  33     with function "=" (  Left  : in ITEM;
	  34                          Right : in ITEM) return Boolean;
	  **
       *****E equality parameters must be same limited type [LRM 6.7/4]
	  **
	  35

    This certainly looks like a compiler bug.  It is illegal to
explicitly declare an equality function for a private type, (except by
using the "Goodenough" workaround), but as a generic subprogram
parameter it is legitimate.

    First report the bug to your compiler vendor, then try one (or
more) of the following workarounds:

   1) It may be the case that if you provide a default the compiler
will let this through. Try:

	with function "=" (  Left  : in ITEM;
                             Right : in ITEM) return Boolean is <>;

   Can't hurt to try, and it really should be written this way anyway.

   2) Change the name of the equality subprogram in your generic formal
parameter list, and modify the body of the package to use the renamed
operation. (Ugh! Not very maintianable.)

   3) Declare a generic as follows:

    generic
      type LP is limited private;
      with function Equal(L,R: LP) return Boolean;
    function "="(L,R: LP) return Boolean;

    function "="(L,R: LP) return Boolean is
    begin return Equal(L,R); end "="
    
    Now modify your code to pass an equality function in under some
other name, then instantiate this function in the package
specification.  This is the Goodenough "trick."

  4) As in one above but hide the instantiation in the body of your
generic.



--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...



  reply	other threads:[~1994-10-04 11:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-03 14:54 Newbie Generic Reg Exp Pattern Matching Question Jimmy Fang
1994-10-04 11:29 ` Robert I. Eachus [this message]
1994-10-04 22:03   ` Stef Van Vlierberghe
1994-10-05  2:21   ` Tucker Taft
1994-10-11 16:10     ` William Fang
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox