comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: QUIZ: To be or not to be (able to post)
Date: 1997/09/30
Date: 1997-09-30T00:00:00+00:00	[thread overview]
Message-ID: <EHC22u.6Gx.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 60n3dm$fhi$1@gonzo.sun3.iaf.nl


Geert Bosch (geert@gonzo.sun3.iaf.nl) wrote:

: OK, here is a nice question for all you Ada experts out there.
: Why isn't the code below not legal? Or is it? If so, why?

:    with Ada.Numerics.Elementary_Functions;
:    procedure Renaming is

:       function Sin (F : Float) return Float;

:       function Sin (X : Float'Base) return Float'Base
: 	 renames Ada.Numerics.Elementary_Functions.Sin;

This is not legal because you use "F" in the declaration of Sin
and you use "X" in the renaming-as-body, and that violates 8.5.4(5) which
requires full conformance of profiles between a renaming-as-body
and the declaration it completes.  

On the other hand, it is OK to use Float in one and Float'Base in the 
other because subtype Float statically matches subtype Float'Base.
They statically match because they are of the same type,
and they both have the "null" constraint.  See 4.9.1(2) and 3.5.7(12).

: ...
: What does your favorite compiler say? 

It complains as follows:

    6     function Sin (X : Float'Base) return Float'Base
                   *
*****Error: LRM:8.5.4(5) a renaming-as-body must be fully conformant with the
*****        declaration it completes, continuing
    7         renames Ada.Numerics.Elementary_Functions.Sin;

: ... And the others? ;-)

I haven't tried any others on this.

: Regards,
:    Geert

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




  reply	other threads:[~1997-09-30  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-29  0:00 QUIZ: To be or not to be (able to post) Geert Bosch
1997-09-30  0:00 ` Tucker Taft [this message]
1997-09-30  0:00 ` Matthew Heaney
1997-10-02  0:00 ` Joel VanLaven
1997-10-02  0:00   ` Tucker Taft
1997-10-02  0:00     ` Joel VanLaven
1997-10-03  0:00       ` Robert A Duff
replies disabled

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