TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date:
Mon, 26 Nov 2001 16:31:38 -0800
Reply-To:
Ed Colbert <[log in to unmask]>
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
quoted-printable
Content-Type:
text/plain; charset="iso-8859-1"
Organization:
Absolute Software Co., Inc.
From:
Ed Colbert <[log in to unmask]>
Parts/Attachments:
text/plain (103 lines)
Hi All,

About 3 months I posted a question on comp.lang.ada.  Tucker responded.
I posted some follow up questions, but never saw a response.  I hope
that Tucker or someone on this mail list might be able to answer my
questions.

Take care,
Ed

----------------------------------------------------------------
"Always do right.  It will please a few and astonish the rest."
 Mark Twain
----------------------------------------------------------------
Edward Colbert
President
Absolute Software Co., Inc.
1444 Sapphire Dr.
Carlsbad, CA 92009-1200
Phone:   (760) 929-0612
FAX:     (760) 929-0236
E-Mail:  [log in to unmask]
Website: www.abssw.com


-----Original Message-----
Hi Tucker,

> > Hi All,
> >
> > Below is a simplified example from Richard Riehle's & my course on 
> > Ada. GNAT v3.13p says that the call Is_Item is an ambiguous 
> > expression, and ObjectAda v 7.2 says the statement is illegal 
> > based on LRM 5.2(6).  Both Richard and I thought that the 
> > expression is tag indeterminate, LRM 3.9.2(6), and would static 
> > resolved, LRM 3.9.2(19).  Are Richard and I missing something or 
> > are both compilers wrong?
>
> The call on Is_Item is ambiguous, even though one of the possible 
> interpretations (the one returning type T1) violates 5.2(6).  This 
> is one of those cases where the overload resolution rules are less 
> picky than the legality rules, which can be a bit confusing.
>
> ObjectAda is not being very helpful by telling you that one of the 
> interpretations is illegal, without first telling you that the 
> expression is considered ambiguous by the overloading rules.
>

Why is the expression ambiguous?  Isn't the tag of C, which in this 
case is compile time determinable, used to resolve the call to Is_Item 
per 5.2(9)?

I suppose it could be ambiguous if the expression is evaluated first 
as allowed by 5.2(7); but then when would 5.2(8-10) apply?

> In any case, if only the Is_Item that returned type T1 were directly 
> visible, the expression would not be ambiguous, and the call would 
> be legal.  It would involve a "dispatching on result" where the tag 
> of "C" would determine which body of Is_Item were called.
>
> In general the overload resolution and legality rules relating to 
> classwide assignment are confusing at best.  We tried other rules, 
> but they had worse problems, so I suppose the current rules are the 
> best of a set of unpleasant alternatives. ObjectAda's error message 
> was unfortunately only adding to the confusion.
>

Clearly, something is confusing Richard & I.

> >
> > package Dispatching_Examples
> > is
> >   type T1 is tagged private;
> >   function Is_Item return T1;
> >
> >   type T2 is new T1 with private;
> >   function Is_Item return T2;
> >
> > private
> >    -- full definition of T1 and T2
> >   type T1 is tagged null record;
> >   type T2 is new T1 with null record;
> > end Dispatching_Examples;
> >
> > with Dispatching_Examples;
> > use Dispatching_Examples;
> > procedure Dispatching_Examples_Driver is
> >     A, B : T1;                    -- simple variables
> >     Q, R : T2;                    -- simple variables
> >     C    : T1'Class := A;     -- class-wide variable
> >     D    : T2'Class := R ;    -- class-wide variable
> > begin
> >     C := Is_Item ;              -- static resolution?
> > end Dispatching_Examples_Driver;
>
> --
> -Tucker Taft   [log in to unmask]   http://www.avercom.net
> Chief Technology Officer, AverCom Corporation (A Titan Company) 
> Bedford, MA  USA (AverCom was formerly the Commercial Division of
AverStar:
> http://www.averstar.com/~stt)
>

ATOM RSS1 RSS2