comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Rohan <michael@zanyblue.com>
Subject: Re: Formatted IO - Fortran style or similar.
Date: Mon, 30 Jul 2012 11:57:12 -0700 (PDT)
Date: 2012-07-30T11:57:12-07:00	[thread overview]
Message-ID: <37475541-c2ae-48ca-8a52-3ae707ba8860@googlegroups.com> (raw)
In-Reply-To: <jv5lta$4dn$1@news.ox.ac.uk>

On Monday, July 30, 2012 2:59:07 AM UTC-7, Ian Clifton wrote:
> Mark Murray <w.h.oami@example.com> writes:
> 
> 
> 
> > Is there anyting in the Ada Standard Library (or the language itself)
> 
> > that acts /in loco/ Fortran's formatted I/O or C's printf()/scanf()?
> 
> 
> 
> > I know these can be written as required, and I know that there are ways
> 
> > to call C's printf()/scanf() functions from Ada, but I'm interested to
> 
> > see if there is not already something "in the box". Yes, I'm aware of
> 
> > the formatting capabilities of put()/get(), but that's not quite what
> 
> > I'm wondering about.
> 
> 
> 
> I’m not quite sure what facilities you’re after—I don’t know C’s
> 
> printf()/scanf(), but presumably they are quite different from Fortran’s
> 
> format control—but I suspect the answer is going to be “Ada’s approach
> 
> is different” (see below).
> 
> 
> 
> > I could have sworn I saw a PL/1-style "picture" version of this, but I'm
> 
> > coming round to believing that this was "customer code", not standard
> 
> > library.
> 
> 
> 
> Here, you could be thinking about “Edited Output for Decimal types”,
> 
> described in the ARM Appendix F. 
> 
> 
> 
> > PS: Is it really the case that put(some_integer,16) will _always_
> 
> > print the '16#9999#' format, and that there is on way _in_the_
> 
> > _standard_library_ of *not* getting the '16#.....#' wrapper?
> 
> > Yes, I know there are ways you can get rid of it (eg with a slice), or
> 
> > by "rolling your own" - alternatives aren't my question here :-).
> 
> 
> 
> I believe Ada’s approach is to specify the results of
> 
> put(some_integer,16) sufficiently carefully that you can do such
> 
> post‐processing with the provided string manipulation packages and be
> 
> confident of the final result. In other words, what you are trying to
> 
> avoid ARE the language’s facilities for doing this sort of thing. I ought
> 
> to mention in passing, the Ada.Text_IO packages are a little
> 
> controversial, many dislike them, but I believe they are under‐rated.
> 
> 
> 
> -- 
> 
> Ian ◎

Hi,

While the intent of my library (ZanyBlue) is currently focused on localization
support, I do support ad hoc in lining of messages (they should be externalized
to a properties file), e.g.,

   Print_Line ("Vector norm is {0,real,10.2f} with rank of {1,integer}",
               +Norm, +Rank);

Note, while type info is given in the in line message string, the library does
not do type checking for these ad hoc strings.  You would need externalized and
use assessors, e.g.,

Summary=Vector norm is {0,real,10.2f} with rank of {1,integer}

with

   Print_Summary (+Norm, +Rank);

in the code and let the compiler do the type checking.

See http://zanyblue.sourceforge.net



  reply	other threads:[~2012-08-02 12:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-30  8:50 Formatted IO - Fortran style or similar Mark Murray
2012-07-30  9:59 ` Ian Clifton
2012-07-30 18:57   ` Michael Rohan [this message]
2012-07-30 22:12   ` Mark Murray
2012-07-31  7:17     ` Dmitry A. Kazakov
     [not found]     ` <npbe18d3o3gdc2ut41f1codvv6rhfgidr3@invalid.netcom.com>
2012-07-31 11:56       ` Jacob Sparre Andersen
2012-07-31 15:12         ` stefan-lucks
2012-07-31 17:34           ` Adam Beneschan
2012-08-01  6:56             ` stefan-lucks
     [not found]           ` <be5g18p0gnf2ocdf3hmgjslgnu0jogrh91@invalid.netcom.com>
2012-08-01  6:48             ` stefan-lucks
2012-08-01  8:09           ` Jacob Sparre Andersen
2012-08-01 10:28             ` Georg Bauhaus
2012-08-01 16:28             ` Simon Wright
2012-08-01 19:14             ` Michael Rohan
replies disabled

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