comp.lang.ada
 help / color / mirror / Atom feed
* When/Why can a compiler reject an operator but accept a name?
@ 2002-07-05 17:08 Wes Groleau
  2002-07-06 23:26 ` Robert A Duff
  2002-07-08 12:17 ` Antonio Duran
  0 siblings, 2 replies; 5+ messages in thread
From: Wes Groleau @ 2002-07-05 17:08 UTC (permalink / raw)


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!)

-- 
Wes Groleau
http://freepages.rootsweb.com/~wgroleau



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When/Why can a compiler reject an operator but accept a name?
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Robert A Duff @ 2002-07-06 23:26 UTC (permalink / raw)


Wes Groleau <wesgroleau@despammed.com> writes:

> 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.

Sounds like a compiler bug, although I can't be sure without seeing all
the code (e.g., you didn't show the code for Ord_Check).

> Does using an operator instead of a name make the
> function Intrinsic?

No.

> 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!)

True.  Show us a complete example.

- Bob



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When/Why can a compiler reject an operator but accept a name?
  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 12:17 ` Antonio Duran
  2002-07-08 15:27   ` Wes Groleau
  1 sibling, 1 reply; 5+ messages in thread
From: Antonio Duran @ 2002-07-08 12:17 UTC (permalink / raw)


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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When/Why can a compiler reject an operator but accept a name?
  2002-07-06 23:26 ` Robert A Duff
@ 2002-07-08 15:22   ` Wes Groleau
  0 siblings, 0 replies; 5+ messages in thread
From: Wes Groleau @ 2002-07-08 15:22 UTC (permalink / raw)


> > 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.
> 
> Sounds like a compiler bug, although I can't be sure without seeing all
> the code (e.g., you didn't show the code for Ord_Check).

Sorry for being a little vague.  ">" was/is a somewhat
complicated function, and all I did to make it compile
was change the designator to "Ord_Check" in both the
declaration and all references.

I would normally compare the GNAT behavior, but
our admins had a bit of trouble replacing 3.14
with the integrated GCC 3.1 suite.

-- 
Wes Groleau
http://freepages.rootsweb.com/~wgroleau



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When/Why can a compiler reject an operator but accept a name?
  2002-07-08 12:17 ` Antonio Duran
@ 2002-07-08 15:27   ` Wes Groleau
  0 siblings, 0 replies; 5+ messages in thread
From: Wes Groleau @ 2002-07-08 15:27 UTC (permalink / raw)



> 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:

I hadn't thought of that--good point.
However, the generic never uses ">"
nor has it as a parameter.  And the
type "Item" is an access type.  So
I don't think that's it in this case.

I reported it as a bug to the vendor,
but I'm still not 100% certain.

-- 
Wes Groleau
http://freepages.rootsweb.com/~wgroleau



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-07-08 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2002-07-08 15:27   ` Wes Groleau

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