From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,628d2a493f1e203d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: Subtype conformance... not what I was expecting. Date: Wed, 26 Jul 2006 18:58:13 +1200 Organization: Ihug Ltd Message-ID: <1h2ec21g2aummifj08diesaloklm54rsef@4ax.com> References: <44c6db66$0$2928$4d3efbfe@news.sover.net> NNTP-Posting-Host: 203.118.188.194 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: lust.ihug.co.nz 1153897003 28374 203.118.188.194 (26 Jul 2006 06:56:43 GMT) X-Complaints-To: abuse@ihug.co.nz NNTP-Posting-Date: Wed, 26 Jul 2006 06:56:43 +0000 (UTC) X-Newsreader: Forte Agent 3.1/32.783 Xref: g2news2.google.com comp.lang.ada:5926 Date: 2006-07-26T18:58:13+12:00 List-Id: 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