comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ijs.co.nz>
Subject: Re: Subtype conformance... not what I was expecting.
Date: Wed, 26 Jul 2006 18:58:13 +1200
Date: 2006-07-26T18:58:13+12:00	[thread overview]
Message-ID: <1h2ec21g2aummifj08diesaloklm54rsef@4ax.com> (raw)
In-Reply-To: 44c6db66$0$2928$4d3efbfe@news.sover.net

On Tue, 25 Jul 2006 23:02:56 -0400, "Peter C. Chapin" wrote:

>procedure Check is
>   subtype Narrow is Integer range -10 .. 10;
>   type Function_Ptr is access function (X : Narrow) return Integer;
>
>   function F (Para : Integer) return Narrow is
>   begin
>      return Para;
>   end F;
>
>   G        : Function_Ptr := F'Access;
>   Result   : Integer;
>begin
>   Result := G (0);
>end Check;    --  Redon to pass GNAT style checking
...
>However, this seems overly restrictive. I'm curious about 
>the rationale for this restriction.


(1) In general, a reference to the Ada 95 Reference Manual might be
  obtained by using the Aonix Object Ada compiler.

(2) I guess that the current design is better. You have not said how
  that is better. 

  When there is a range subtype then it is up to the source code to
  make the subtype seem completely different, or seem very similar.
  Above, for your view to result, it is suggested that the subtype is
  similar. Eg.

  type Degrees is new Real;
  subtype Azimuth is Degrees range 0.0 .. 360.0;
  subtype Harmonic_5 is Azimuth range 0.0 .. 72.0;

(3) A workaround could be simple: have a record with 2 pointer fields.
  Also there is the union type (a GNAT 3.15p extension):
     pragma Unchecked_Union (Name) "corresponds exactly to a C union")

(4) Record keeping of the ARG is bad and the matter raised is judged
  minor, by me. If not minor, then maybe Jeffrey Carter would write
  (a man of what remains of Team-Ada).
  My last message about tagged types is proper while official Ada
  collapses. Different forces can lead to the high-priced seize-up of
  compilers of IBM.

(5) GNAT 3.15p (from the Internet) says:
   "error: not subtype conformant with declaration at line xxx"

(6) An argument might be that that safety wins and the convenience is
  worse than small.
  Another argument is to say that the source code is made to be
  ambiguous on whether the range checking of input and output of
  the function, occur inside of the function's code, or in the code
  at the site where it is called.


-- Craig Carey



  reply	other threads:[~2006-07-26  6:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-26  3:02 Subtype conformance... not what I was expecting Peter C. Chapin
2006-07-26  6:58 ` Craig Carey [this message]
2006-07-26  7:54 ` Dmitry A. Kazakov
2006-07-26 14:32   ` Peter C. Chapin
2006-07-26 15:38     ` Georg Bauhaus
2006-07-27  0:02       ` Peter C. Chapin
2006-07-26 18:40     ` Dmitry A. Kazakov
2006-07-27  0:00       ` Peter C. Chapin
2006-07-26  8:06 ` Georg Bauhaus
2006-07-26 14:15   ` Peter C. Chapin
2006-07-26 21:23 ` Adam Beneschan
replies disabled

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