comp.lang.ada
 help / color / mirror / Atom feed
From: antonio_duran@hotmail.com (Antonio Duran)
Subject: Re: When/Why can a compiler reject an operator but accept a name?
Date: 8 Jul 2002 05:17:14 -0700
Date: 2002-07-08T12:17:15+00:00	[thread overview]
Message-ID: <e1a50f2.0207080417.17b77cdd@posting.google.com> (raw)
In-Reply-To: 3D25D271.ACE6DAC8@despammed.com

Wes Groleau <wesgroleau@despammed.com> wrote in message news:<3D25D271.ACE6DAC8@despammed.com>...
> In package G I have:
> 
>     type List_Type is array (Natural range <>) of Item;
> 
>     type Order is access function (Left, Right : in Item) return
> Boolean;
> 
>     procedure Sort (List : in out List_Type; Sequence : in Order);
>     
> 
> In procedure P I had:
> 
>     package I is new G (Item);
> 
>     function "<" (Left, Right : in Item) return Boolean is
> 
>     .....
>     
>     I.Sort (List => List, Sequence => "<"'Access);
> 
>     
> Compiler rejected it, saying:
> 
>    "<" has no definition that matches function (Left, Right : in Item)
> return Boolean [RM_95 3.10.2(32)]
>    
> I replaced "<" with Ord_Check (no other changes), and
> the compiler accepted it.
> 
> Does using an operator instead of a name make the
> function Intrinsic?
> 
> If not, there is no support for rejection in 3.10.2(32)
> Is there any reason elsewhere in the RM to justify this
> odd behavior?
> 
> (Certainly either way, the message could be improved!)

ARM 3.10.2 1 says:

"The attribute Access is used to create access values designating
aliased objects and non-intrinsic subprograms. The
&#8220;accessibility&#8221; rules prevent dangling references (in the
absence of uses of certain unchecked features &#8212; see Section
13)."

So what I think is happening is that you're instanciating G with a
type that has an intrinsic "<" operator. For example, if you use
Integer, in your P procedure you must write a customized "<" operator
like:

with G;

procedure P is
   package I is new G(Integer);

   function "<"(Left, Right: in Integer) return Boolean
   is
   begin
      return Standard."<"(Left, Right);
   end "<";

   -- More stuff here.

begin
   -- More stuff here.
end P;

Regards,
    Antonio Duran.



  parent reply	other threads:[~2002-07-08 12:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-05 17:08 When/Why can a compiler reject an operator but accept a name? Wes Groleau
2002-07-06 23:26 ` Robert A Duff
2002-07-08 15:22   ` Wes Groleau
2002-07-08 12:17 ` Antonio Duran [this message]
2002-07-08 15:27   ` Wes Groleau
replies disabled

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