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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!enother.net!enother.net!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx08.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:35.0) Gecko/20100101 Thunderbird/35.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Generic formals and Aspects References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Sat, 18 Oct 2014 01:43:44 UTC Organization: TeraNews.com Date: Fri, 17 Oct 2014 19:43:37 -0600 X-Received-Bytes: 1585 X-Received-Body-CRC: 2700819741 Xref: news.eternal-september.org comp.lang.ada:22562 Date: 2014-10-17T19:43:37-06:00 List-Id: The following does work, though it doesn't catch it at compile-time: generic type Source_Type is range <>; type Destination_Type is range <>; S_First : Long_Long_Integer:= Long_Long_Integer(Source_Type'First); S_Last : Long_Long_Integer:= Long_Long_Integer(Source_Type'Last); D_First : Long_Long_Integer:= Long_Long_Integer(Destination_Type'First); D_Last : Long_Long_Integer:= Long_Long_Integer(Destination_Type'Last); function Saturate (X : Source_Type) return Destination_Type with Pre => D_First >= S_First and D_Last <= S_Last ; Maybe this would be a good thing to suggest for the corrigenda -- addition of SUBTYPE to generic formals; the purpose thereof would be to "hang" Predicates on and [I think] Static_Predicate could be checked at compile-time.