I'm not sure we should measure the "march of progress" based
on ease of writing print statements, but...

Mike Bates writes:
> If you want to make the contrast more dramatic, add some plain text, a
> variable-length string, and an integer in hexadecimal.
>
> How many lines does it take to do this in Ada, C++, or Java:
>
>       printf("The result for %-30s is %10.2f (%08x)\n", x, y, z);
>
> My question: Has anyone written good Ada equivalents to printf and
> scanf?

In a soon-to-be-released version of TASH, an Ada binding to Tcl/Tk,
you could do the above with the Ada program whose source text is
at the end of this email message.  The output of this program is:

The result for a piece of pi                  is       3.14 (00000059)
The result for a half piece of pi             is       1.57 (00000052)

Of course, this is not pure Ada; it depends on linking with Tcl/Tk
and using the TASH binding.  I haven't yet started scanf and it
probably will not be in the next release of TASH.  By the way,
this new version of TASH will also have regexp capability.

--
Terry J. Westley, Principal Engineer
Veridian Engineering, Calspan Operations
[log in to unmask]   http://www.veridian.com/
-------------------------------------------------------
Author of TASH, an Ada binding to Tcl/Tk.
Visit the TASH web site at http://tash.calspan.com.
-------------------------------------------------------

-------------- Ada source code follows; cut here ------------------
with Ada.Text_IO;
with Tash.Floats;
with Tash.Integers;
with Tash.Lists;
with Tash.Strings;

procedure Test_Format is

   use type Tash.Strings.Tash_String;
   use type Tash.Floats.Tash_Float;
   use type Tash.Integers.Tash_Integer;

   X : Tash.Strings.Tash_String;
   Y : Tash.Floats.Tash_Float;
   Z : Tash.Integers.Tash_Integer;

begin -- Test_Format

   -- Initialize some Tash objects to
   -- hold a string, float, and integer
   ------------------------------------
   X := +"a piece of pi";
   Y := +3.14159;
   Z := +89;

   -- Demonstrate use of C-style printf
   ------------------------------------
   Ada.Text_IO.Put_Line (Tash.Lists.Format (
      FormatString => "The result for %-30s is %10.2f (%08x)",
      Values       => Tash.Lists.Create (X, Y, Z)));

   -- Demonstrate use of C-style printf without explictly
   -- creating the Tash objects: X, Y, and Z
   ------------------------------------------------------
   Ada.Text_IO.Put_Line (
      Tash.Lists.Format (
         "The result for %-30s is %10.2f (%08x)",
         Tash.Lists.Create (+"a half piece of pi", +1.5708, +82)));

end Test_Format;