comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Garlington <garlingtonke@lmtas.lmco.com>
Subject: Re: Leading zeros with Int_IO.Put()? Or another package?
Date: 1996/11/13
Date: 1996-11-13T00:00:00+00:00	[thread overview]
Message-ID: <328A0A7D.21A2@lmtas.lmco.com> (raw)
In-Reply-To: 56bg5v$14u$1@goanna.cs.rmit.edu.au


robin wrote:
> 
> dewar@merv.cs.nyu.edu (Robert Dewar) writes:
> 
>         >robin says
> 
>         >>"Interface to PL/I and you can use standard I/O:
> 
>         >>put edit (n) (P'-99999999');
> 
>         >>and you don't have to worry about whether the number is
>         >>negative either.  The nines in the picture format
>         >>force leading zeros to print.
> 
>         >>And if you want, you can insert commas in the output
>         >>to make it more readable.  The picture specification becomes:
> 
>         >>P'-999,999,999'"
> 
>         >I guess robin knows PL/1 and does not know Ada!
> 
>         >If you want to use picture editing to solve this kind of problem, then
>         >use the picture editing in Ada, no need to wander off into PL/1, even in
>         >the unlikely case that you have a PL/1 compiler at hand. Personally I
>         >dislike the picture stuff in PL/1, they tried to improve on COBOL and
>         >made a mess of it.
> 
> Isn't it amazing!  Robert Dewar [among others] already has
> had an opportunity to reply in this vein to the original
> posting and subsequent ones, but it didn't occur to him to
> do so, more than likely because he didn't know that a limited
> facility existed in Ada.  Instead, he suggested using
> string facilities.

Actually, if you know Ada, it's not amazing at all. The Ada picture I/O is for
decimal types; the original request was for integer types. If you don't want to
convert your type, the suggestion by Dr. Dewar is more straight-forward. If you
do want to use picture I/O, you probably still want to use an abstraction of
this facility to hide the details of type conversion, instantiation of picture I/O,
etc.

Ada people have this perversity of suggesting the most straight-forward and
maintainable approach first. :)

> 
> Below is Robert Dewar's previous posting:
> 
> >This is a place where CLEARLY there is a missing abstraction (Put with
> >leading zeros), and it seems obvious that you fix this in the way that
> >you always do abstraction extension, you create an appropriate abstraction
> >and use it. If it is useful enough, hopefully it gets to be widely available.
> 
> >Note that if you do want to construct on the fly, a much clearer way is to
> >use the string routines from the string packages, which have padding
> >capabilities.
> 
> PL/I is not restricted to picture editing with decimal data,
> (one poster suggested changing to Ada decimal data in order to use
> Ada's limited editing).   PL/I requires *only* the single line:
> 
> put edit (n) (P'-99999999');
> 
> and not the (up to) page of Ada code to implement the
> requirement of the original post.

-- 
LMTAS - "Our Brand Means Quality"
For more info, see http://www.lmtas.com or http://www.lmco.com




  reply	other threads:[~1996-11-13  0:00 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-05  0:00 Leading zeros with Int_IO.Put()? Or another package? J.D. Baldwin
1996-11-05  0:00 ` Samuel Tardieu
1996-11-05  0:00 ` David Shochat
1996-11-08  0:00   ` robin
1996-11-08  0:00     ` Ken Garlington
1996-11-08  0:00     ` Robert Dewar
1996-11-10  0:00       ` Verne Arase
1996-11-13  0:00       ` robin
1996-11-13  0:00         ` Ken Garlington
1996-11-19  0:00           ` robin
1996-11-19  0:00             ` Robert Dewar
1996-11-20  0:00             ` Richard A. O'Keefe
1996-11-20  0:00               ` Robert Dewar
1996-11-20  0:00               ` robin
1996-11-20  0:00                 ` Larry J. Elmore
1996-11-25  0:00                   ` robin
1996-11-25  0:00                     ` Robert Dewar
1996-11-26  0:00                     ` Larry J. Elmore
1996-11-20  0:00                 ` Richard A. O'Keefe
1996-11-22  0:00                   ` robin
1996-11-22  0:00                     ` Richard A. O'Keefe
1996-11-23  0:00                       ` robin
1996-11-20  0:00                 ` Robert Dewar
1996-11-22  0:00                   ` Richard A. O'Keefe
1996-11-25  0:00                   ` shmuel
1996-11-21  0:00                 ` Jerry Coffin
1996-11-22  0:00                 ` Ken Garlington
1996-11-20  0:00             ` Norman H. Cohen
1996-11-22  0:00             ` Ken Garlington
1996-11-27  0:00               ` Verne Arase
1996-12-02  0:00                 ` Ken Garlington
     [not found]             ` <56tjrh$4a <MPLANET.3294c204jcoffin989a3e@news.rmi.net>
1996-11-24  0:00               ` Bert
1996-11-13  0:00       ` robin
1996-11-13  0:00         ` Ken Garlington [this message]
1996-11-19  0:00           ` robin
1996-11-22  0:00             ` Robert Dewar
1996-11-22  0:00             ` Ken Garlington
1996-11-17  0:00         ` Robert Dewar
1996-11-21  0:00   ` Robert I. Eachus
1996-11-22  0:00     ` robin
1996-11-06  0:00 ` Norman H. Cohen
1996-11-07  0:00   ` Pascal Obry
1996-11-07  0:00     ` Norman H. Cohen
1996-11-08  0:00   ` Norman H. Cohen
1996-11-09  0:00     ` Robert Dewar
1996-11-06  0:00 ` Stephen Leake
1996-11-06  0:00 ` Robert I. Eachus
1996-11-08  0:00   ` Norman H. Cohen
1996-11-08  0:00 ` David Emery
1996-11-24  0:00 ` Fergus Henderson
1996-11-24  0:00   ` Robert Dewar
1996-11-25  0:00     ` J. David Bryan
1996-11-25  0:00     ` Larry Kilgallen
1996-11-27  0:00     ` Verne Arase
1996-11-28  0:00   ` Richard A. O'Keefe
  -- strict thread matches above, loose matches on Subject: below --
1996-11-05  0:00 Collection of 2500+ links about Object-Orientation - interested ? Manfred Schneider
1996-11-07  0:00 ` Leading zeros with Int_IO.Put()? Or another package? John Herro
1996-11-07  0:00   ` James Rogers
1996-11-07  0:00   ` Robert Dewar
1996-12-15  0:00 Robert Dewar
replies disabled

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