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!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!enother.net!enother.net!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx01.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:36.0) Gecko/20100101 Thunderbird/36.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Can .ads be compiled alone? References: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com> 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: Fri, 07 Nov 2014 17:14:52 UTC Organization: TeraNews.com Date: Fri, 07 Nov 2014 10:14:54 -0700 X-Received-Bytes: 1833 X-Received-Body-CRC: 3699634096 Xref: news.eternal-september.org comp.lang.ada:23067 Date: 2014-11-07T10:14:54-07:00 List-Id: On 07-Nov-14 00:48, Chris Moore wrote: > > You cannot generate code from a spec. That's not /entirely/ true; in Ada 2012: ----------------------- -- ADS_Example.ads -- ----------------------- pragma Ada_2012; Package ADS_Example is -- The stupid old reverse-a-string beginner's exercise. Function Reverse_String( Input : String ) return string; private Function Reverse_String( Input : String ) return string is (case Input'Length is when 0 | 1 => Input, when others => Input(Input'Last) & Reverse_String( Input(Input'First..Positive'Pred(Input'Last)) ) ); End ADS_Example; --------------- -- Main.ads -- --------------- with Ada.Text_IO, ADS_Example; Procedure Main is Text : constant String:= "This is a test."; begin Ada.Text_IO.Put_Line( "Starting." ); Ada.Text_IO.Put_Line( "Text: " & Text ); Ada.Text_IO.Put_Line( "Reversed: " & ADS_Example.Reverse_String(Text) ); Ada.Text_IO.Put_Line( "Finished." ); end Main;