comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <OneWingedShark@gmail.com>
Subject: Re: Can .ads be compiled alone?
Date: Fri, 07 Nov 2014 10:14:54 -0700
Date: 2014-11-07T10:14:54-07:00	[thread overview]
Message-ID: <g677w.104412$5U6.30214@fx01.iad> (raw)
In-Reply-To: <rP_6w.67103$7w2.45243@fx01.am4>

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;

  parent reply	other threads:[~2014-11-07 17:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07  5:21 Can .ads be compiled alone? moixa
2014-11-07  6:09 ` Jeffrey Carter
2014-11-07 17:26   ` Robert A Duff
2014-11-07 17:41     ` Jeffrey Carter
2014-11-07  6:20 ` J-P. Rosen
2014-11-07  7:48 ` Chris Moore
2014-11-07 14:54   ` Tero Koskinen
2014-11-07 15:49     ` Björn Lundin
2014-11-07 16:29       ` G.B.
2014-11-08 13:01         ` moixa
2014-11-08 14:55           ` G.B.
2014-11-07 16:29       ` G.B.
2014-11-07 16:44     ` Adam Beneschan
2014-11-07 17:14   ` Shark8 [this message]
2014-11-08 21:31     ` Chris Moore
2014-11-07 16:50 ` Adam Beneschan
2014-11-07 17:14   ` Robert A Duff
2014-11-08  2:01     ` Randy Brukardt
2014-11-15 12:54 ` rriehle
2014-11-15 19:17   ` Robert A Duff
2014-11-15 19:19     ` Robert A Duff
2014-11-17 15:52       ` Adam Beneschan
2014-11-17  0:07     ` rriehle
2014-11-17  6:50       ` Simon Wright
2014-11-24  3:16     ` rriehle
2014-11-24  6:34       ` Jeffrey Carter
replies disabled

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