comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: Ada noob here! Is Ada widely used?
  2010-06-05  7:47  4%   ` Georg Bauhaus
@ 2010-06-05 22:43  0%     ` starwars
  0 siblings, 0 replies; 21+ results
From: starwars @ 2010-06-05 22:43 UTC (permalink / raw)


> How do Interfaces.COBOL and Ada.Text_IO.Editing fit in here?

The support is there to do the work, it's just much harder and uglier to do
in Ada than COBOL. COBOL has built-in types for money  and editing (COMP-3)
but in Ada you have to have the Data Processing Annex and unfortunately
many toolchains don't offer it. Even with the support, it's painful to do
financial reporting on a large scale in Ada. COBOL wins here. It should, it
was designed specifically for this above all else.




^ permalink raw reply	[relevance 0%]

* Re: Ada noob here! Is Ada widely used?
  @ 2010-06-05  7:47  4%   ` Georg Bauhaus
  2010-06-05 22:43  0%     ` starwars
  0 siblings, 1 reply; 21+ results
From: Georg Bauhaus @ 2010-06-05  7:47 UTC (permalink / raw)


On 6/4/10 9:23 PM, Fritz Wuehler wrote:

> Ada is better than COBOL except in one way. It is easier to write reports
> (the bulk of financial processing) and define decimal (money) fields in
> COBOL than Ada. It *could* have been used in financial processing, but
> COBOL had two decades and a half of a head start.

How do Interfaces.COBOL and Ada.Text_IO.Editing fit in here?





^ permalink raw reply	[relevance 4%]

* Re: Ada Function for logMsg or printf
  @ 2008-07-31 10:44  4%           ` Georg Bauhaus
  0 siblings, 0 replies; 21+ results
From: Georg Bauhaus @ 2008-07-31 10:44 UTC (permalink / raw)


richtmyer@cox.net schrieb:
> On Jul 28, 3:52 am, Markus Schoepflin <nos...@no.spam> wrote:
>> Fionn Mac Cumhaill wrote:
>>> On Sun, 27 Jul 2008 04:33:39 -0700 (PDT), richtm...@cox.net wrote:
>>>> On Jul 27, 1:47 am, tmo...@acm.org wrote:
> 
>>> http://www.adapower.com/index.php?Command=Class&ClassID=AdaLibs&CID=375
>> This looks interesting, unfortunately pressing the download link gives a
>> 404: The requested URL /adapower1/reuse/Formatted_Output.zip was not found
>> on this server.

> Anybody have a copy?


Maybe Ada.Text_IO.Editing can fill the gap?

--
Georg Bauhaus
Y A Time Drain  http://www.9toX.de



^ permalink raw reply	[relevance 4%]

* Re: Predefined Packages
  @ 2007-06-14 19:58  4%   ` Randy Brukardt
  0 siblings, 0 replies; 21+ results
From: Randy Brukardt @ 2007-06-14 19:58 UTC (permalink / raw)


"Ludovic Brenta" <ludovic@ludovic-brenta.org> wrote in message
news:1181828462.112461.278920@z28g2000prd.googlegroups.com...
> On Jun 14, 3:07 pm, a...@anon.org (anon) wrote:
> > Trying to find a list of predefined packages that are common in all
> > Ada version both commercial and free. Like "Ada.Text_IO", which
> > should be in all version.
> >
> > But package "GNAT.IO" which is in the GNAT and GNU Ada version
> > are limited to theses two version of Ada.
> >
> > If you could post a url address or maybe a dir listing of your.
> > You can skip the GNU/GNAT I have that version.
> >
> >   Thanks
>
> http://www.adaic.com/standards/05rm/html/RM-Q-1.html

But beware: not all compilers support the annexes C-H, so packages defined
in those may not be available. (An obvious example is Ada.Text_IO.Editing.)

For the OP: if it isn't defined in the Ada standard, you can be sure that it
isn't present in all Ada compilers. Packages defined by the different
vendors tend to be very different. Thus the listing given above is about all
that you can count on.

                     Randy.





^ permalink raw reply	[relevance 4%]

* Re: Regular Expressions in Ada 2005?
  @ 2006-11-08 21:14  4% ` Georg Bauhaus
  0 siblings, 0 replies; 21+ results
From: Georg Bauhaus @ 2006-11-08 21:14 UTC (permalink / raw)


On Wed, 2006-11-08 at 12:53 -0800, matthias.kistler@gmx.de wrote:
> Hi!
> 
> Does anybody know, if it's possible to use regular expressions in Ada
> 2005? I come from Perl and I'm very interested in Ada but it's useless
> for me without the possibility of using regular expressions similar to
> Perl.

Ada comes with a rich set of string manipulation packages,
Ada.Strings.*, Ada.Characters.*, Ada.*Text_IO.Editing.

They cover a fair bit of what you would do using Perl's expressions
and translation operators in a sane way.

>   I found a GNAT-package providing only a regex-matcher. But I also
> need a replacer. Elsewise it'd be useless for me.

The GNAT packages do provide scanning and replacement. There is a
tutorial in the package specifications.

Example programs:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=regexdna&lang=gnat&id=3
http://shootout.alioth.debian.org/gp4/benchmark.php?test=regexdna&lang=gnat&id=4

#3 uses Unix style regular expressions.
#4 uses SPITBOL regular expressions.

SPITBOL patterns are quite powerful and fast, in fact you
can write an entire program just as a pattern. But don't do
that.

Georg 






^ permalink raw reply	[relevance 4%]

* Re: Debugger Rant (was Re: How to debug an Ada program)
  @ 2003-07-11 18:42  5%       ` Robert I. Eachus
  0 siblings, 0 replies; 21+ results
From: Robert I. Eachus @ 2003-07-11 18:42 UTC (permalink / raw)


Jerry Petrey wrote:

> I certainly agree with you Marc.  While a debugger may not be needed as much in
> Ada (and certainly not as much for the simpler problems) as in other languages, it
> is an indispensable tool in complex Ada applications, especially in the real-time,
> embedded world.

Shurg!  I guess I have internalized a style of programming once known as 
  "Design to test."  In other words, all (formal) requirements are 
testable, and you design and code from day one to make passing those 
tests as easy as possible.

I was recently working on a bug in Ada.Text_IO.Editing in GNAT.  I 
didn't use a debugger, and couldn't imagine the pain of trying to.  The 
issue of course, was that any changes to make "#*#" recognized as 
invalid had to leave the behavior on hundreds of test cases unchanged. 
I needed automated testing that did not depend on the debugger.  (In 
fact several times I got fixes bounced because I wasn't using as many 
test cases as ACT.)

Even if you want to consider Ada.Text_IO.Editing as separate from GNAT, 
and Ada.Text_IO, it has about 3000 lines including two parsers...

-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




^ permalink raw reply	[relevance 5%]

* Re: Floating Decimal Package/Library?
  2002-07-17  4:41  7% ` tmoran
@ 2002-07-17 16:30  0%   ` Warren W. Gay VE3WWG
  0 siblings, 0 replies; 21+ results
From: Warren W. Gay VE3WWG @ 2002-07-17 16:30 UTC (permalink / raw)


tmoran@acm.org wrote:

>>Since Turkish Lira have been mentioned, when one tries to directly
>>calculate currency equivalents based on the exchange rate
>>
>   Using Gnat, the program:
> with Ada.Text_IO;
> with Ada.Text_IO.Editing;
> procedure Turk is
>   type Turkish is delta 0.01 digits 18;
>   type US is delta 0.01 digits 18;
> 
>   package Turkish_Output is new Ada.Text_IO.Editing.Decimal_Output(Turkish);
>   package US_Output is new Ada.Text_IO.Editing.Decimal_Output(US);
> 
>   Money_Pic: constant Ada.Text_IO.Editing.Picture
>     := Ada.Text_IO.Editing.To_Picture("-$$_$$$_$$$_$$$_$$$_$$9.99");
> 
>   Dollars : US := 3_300_000_000.00;
>   Lira    : Turkish;
> 
> begin
>   Lira := Turkish(Dollars * 1097213.08);
>   Ada.Text_IO.Put_Line(US_Output.Image(Dollars, Money_Pic)
>                        & Turkish_Output.Image(Lira, Money_Pic));
> end Turk;
>   produced:
>          $3,300,000,000.00 $3,620,803,164,000,000.00
> Perhaps the IMF's accounting department has a library to go higher, but
> $3.3 billion should satisfy most of the rest of us.


Not true. Look at mutual fund holdings, or your bank's, or
pension funds. To deal with these kinds of issues, INFORMIX
and Oracle (for example) do supply businesses with Decimal
library routines for use in applications. This allows them
to accurately deal with the precision and exactness of
the values involved. Accountants and auditors just
blink at you when you try to explain about binary
floating point "error". 8-)

The example above shows the currency to only 2 decimal 

places and already 

uses 18 digits. We typically use 4 or more decimal places,
because not all currencies are held to 2 decimal places
(especially after conversion). In light of the example above,
we already need 20-22 digits.

Someone else suggested "why not keep all amounts in

dollars?"  There are numerous situations where this doesn't
work well. One is when you buy a security (stock) on an
exchange: you keep on record what you paid for it -- in
the currency of that trade. You keep the exchange rate
history in a separate table. If you store the trade price
amount in dollars, you mix exchange rate and price
in one value. This can lead to precision errors (at least
for some data types and precision ranges), and it makes
life much more complicated for your software. Imagine that
the dollar amount is incorrect because the exchange rate
was wrong. Now you have to find all trades in that currency,
divide out the wrong exchange rate, multiply in the new.
Very messy, and the very sort of things that make programmers
and auditors alike, cringe.

It is much purer as a data model to store price and
exchange rate separately and perform currency
conversions only when required. This way, if your trade
was done in Liras, the amount will be reported on the
report precisely, and you can still compute holdings
in Canadian or US currency on demand.

Warren.





^ permalink raw reply	[relevance 0%]

* RE: Floating Decimal Package/Library?
  @ 2002-07-17  4:41  7% ` tmoran
  2002-07-17 16:30  0%   ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 21+ results
From: tmoran @ 2002-07-17  4:41 UTC (permalink / raw)


> Since Turkish Lira have been mentioned, when one tries to directly
> calculate currency equivalents based on the exchange rate
  Using Gnat, the program:
with Ada.Text_IO;
with Ada.Text_IO.Editing;
procedure Turk is
  type Turkish is delta 0.01 digits 18;
  type US is delta 0.01 digits 18;

  package Turkish_Output is new Ada.Text_IO.Editing.Decimal_Output(Turkish);
  package US_Output is new Ada.Text_IO.Editing.Decimal_Output(US);

  Money_Pic: constant Ada.Text_IO.Editing.Picture
    := Ada.Text_IO.Editing.To_Picture("-$$_$$$_$$$_$$$_$$$_$$9.99");

  Dollars : US := 3_300_000_000.00;
  Lira    : Turkish;

begin
  Lira := Turkish(Dollars * 1097213.08);
  Ada.Text_IO.Put_Line(US_Output.Image(Dollars, Money_Pic)
                       & Turkish_Output.Image(Lira, Money_Pic));
end Turk;
  produced:
         $3,300,000,000.00 $3,620,803,164,000,000.00
Perhaps the IMF's accounting department has a library to go higher, but
$3.3 billion should satisfy most of the rest of us.

> Again, I would prefer to use decimals for engineering and scientific
> calculations.
  I agree for that you would want floating point decimal.



^ permalink raw reply	[relevance 7%]

* Re: integer'image
  @ 2000-04-18  0:00  4%       ` Marin D. Condic
  0 siblings, 0 replies; 21+ results
From: Marin D. Condic @ 2000-04-18  0:00 UTC (permalink / raw)


Ted Dennison wrote:
> 
> ...which saves one from doing the 'Image twice. Damn, why didn't I think
> of that? :-)
> 
> Thanks for the tip Marin.
> 
Oh hell! What do you say we co-write a paper called "How many ways can
you get an integer into a string in Ada?" :-)

Of course the *precise* behavior desired may make other techniques more
useful. Start fooling with Ada.Strings.Fixed and you have to do
justifications and trimming and stuff like that. Maybe we should look at
things like Ada.Text_IO.Editing as yet another option for getting
numbers into a string.

MDC
-- 
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

"I'd trade it all for just a little more"
    --  Charles Montgomery Burns, [4F10]
======================================================================




^ permalink raw reply	[relevance 4%]

* Re: I18N gettext style
  @ 2000-03-05  0:00  6% ` tmoran
  0 siblings, 0 replies; 21+ results
From: tmoran @ 2000-03-05  0:00 UTC (permalink / raw)


>Is there any reason you used print0, print1, print2, instead of
>print, print, print? My instinct is to overload them.
  The only reason is that I was trying to code after midnight. #.#
>Or %1 and %2, for compatibility with current systems.
  How about producing:

Hi!
Hi! There are 3 widgets!
Hi! There are 3 parts, code 1234!
Hi! For $99.95 you can buy 3 parts, code 1234!

  using

with ada.text_io,
     ada.text_io.editing;
 use ada.text_io,
     ada.text_io.editing;
procedure test is

  procedure print(s : in string;
                  p1 : in string := "";
                  p2 : in string := "";
                  p3 : in string := "") is
    si : integer := s'first;
  begin
    while si <= s'last loop
      if si < s'last and then s(si) = '%' then
        case s(si+1) is
          when '1' => put(p1);
          when '2' => put(p2);
          when '3' => put(p3);
          when others => null;
        end case;
        si := si+2;
      else
        put(s(si));
        si := si+1;
      end if;
    end loop;
    new_line;
  end print;

  count : integer := 3;
  id : integer := 1234;

  type money is delta 0.01 digits 5;
  package print_money is new ada.text_io.editing.decimal_output(money);
  money_picture : constant picture := to_picture("-$$9.99");

  price : money := 99.95;

begin
  print("Hi!");
  print("Hi! There are%1 widgets!",
        integer'image(count));
  print("Hi! There are%1 parts, code%2!",
        integer'image(count),
        integer'image(id));
  print("Hi! For%3 you can buy%1 parts, code%2!",
        integer'image(count),
        integer'image(id),
        print_money.image(price, money_picture));
end test;




^ permalink raw reply	[relevance 6%]

* Re: Ada vs C++ vs Java
  @ 1999-01-22  0:00  4%                         ` adam
  0 siblings, 0 replies; 21+ results
From: adam @ 1999-01-22  0:00 UTC (permalink / raw)


In article <m3d847sjjp.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:

> Ada and Java are the only mainstream languages that have built-in
> support for currency. . . .

I have to dispute this.  COBOL has always had support for currency; I
believe it was the first language with features for printing numbers with a
dollar sign and embedded commas, and even gave you the option of putting
asterisks in between the dollar sign and the number for check protection.
However, Ada 95 has added the package Ada.Text_IO.Editing, which should give
it at least as good support for currency as what COBOL has.

Yes, I know you meant to type "concurrency"... I'm just being silly...

:)
				-- Adam

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[relevance 4%]

* Re: Newbie Q: Zero fill in Put
  @ 1997-09-05  0:00  4%   ` Robert Dewar
  0 siblings, 0 replies; 21+ results
From: Robert Dewar @ 1997-09-05  0:00 UTC (permalink / raw)



Jacob says (of outputting numbers with leading zeroes)

<<I do not think there is a routine to do it in the standard libraries, but it
is not hard to implement with a few calls to routines in the standard
libraries.>>


No, that's wrong, there are extensive formatting capabilities defined in
Ada 95 that share the concept of COBOL picture strings. This is a particularly
trivial case (you just use a picture of all 9's). Have a look at the package
Ada.Text_IO.Editing in annex G. This capability is fully implemented in all
current versions of GNAT.





^ permalink raw reply	[relevance 4%]

* Re: Newbie Q: Zero fill in Put
      1997-09-03  0:00  6% ` Pascal Obry
@ 1997-09-04  0:00  4% ` Robert Dewar
  2 siblings, 0 replies; 21+ results
From: Robert Dewar @ 1997-09-04  0:00 UTC (permalink / raw)



<<How do I make it output with leading zeros,
eg: 02, 002, 00000002, etc?  The width parameter
seems to only fill with spaces.>>

If you are using GNAT, which fully implements the information systems
annex, then consider using Ada.Text_IO.Editing with an appropriate
picture string.






^ permalink raw reply	[relevance 4%]

* Re: Newbie Q: Zero fill in Put
    @ 1997-09-03  0:00  6% ` Pascal Obry
  1997-09-04  0:00  4% ` Robert Dewar
  2 siblings, 0 replies; 21+ results
From: Pascal Obry @ 1997-09-03  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]




Another solution is to use the Ada.Text_IO.Editing package.
This package is able to format decimal number with great simplicity
(the functionalities are derived from the COBOL pictures) and is
very powerfull.

This is maybe a complex solution for a simple problem but in some
others complex cases it is very usefull.

-----------------------------------------

with Ada.Text_IO.Editing;

procedure Zfill is

   use Ada;

   type Num is delta 0.1 digits 10;

   package Text_Editing is new Text_IO.Editing.Decimal_Output (Num);

   X : Integer := 2;

begin
   Text_Editing.Put (Num (X), Pic => Text_IO.Editing.To_Picture ("999"));
end Zfill;

--

--|------------------------------------------------------------
--| Pascal Obry                               Team-Ada Member |
--|                                                           |
--| EDF-DER-IPN-SID- Ing�nierie des Syst�mes d'Informations   |
--|                                                           |
--| Bureau G1-010           e-mail: pascal.obry@der.edfgdf.fr |
--| 1 Av G�n�ral de Gaulle  voice : +33-1-47.65.50.91         |
--| 92141 Clamart CEDEX     fax   : +33-1-47.65.50.07         |
--| FRANCE                                                    |
--|------------------------------------------------------------
--|
--|   http://ourworld.compuserve.com/homepages/pascal_obry
--|
--|   "The best way to travel is by means of imagination"








^ permalink raw reply	[relevance 6%]

* Re: Leading zeros with Int_IO.Put()? Or another package?
  1996-11-27  0:00  4%               ` Verne Arase
@ 1996-12-02  0:00  4%                 ` Ken Garlington
  0 siblings, 0 replies; 21+ results
From: Ken Garlington @ 1996-12-02  0:00 UTC (permalink / raw)



Verne Arase wrote:
> 
> In article <3295F2A9.1EF0@lmtas.lmco.com>,
> Ken Garlington <garlingtonke@lmtas.lmco.com> wrote:
> 
>  >  use Ada.Text_IO.Editing;
>  >  ...
>  >  package Edited_IO is new Decimal_Output (type);
>  >  ...
>  >  Edited_IO.Put (n, To_Picture ("-99999999"));
>  >
>  >Interesting. They look reasonably similar to me. If anything,
>  >the Ada version makes it clear from the text that this
>  >I/O is using the Picture feature of the language. However,
>  >if you believe "P" is more readable in this regard, I
>  >suppose we'll have to agree to disagree...
> 
> Well, we are talking about a langugage primative rather than a subroutine
> library.

I'm not sure what a "language primitive" is, but any Ada compiler that implements
the Information Systems annex of the Ada standard (ISO/IEC 8652:1995) will support
the three lines written above (which can also be re-written as two slightly longer
lines, if desired). Specifically, the generic package
Ada.Text_IO.Editing.Decimal_Output is supplied by the compiler, just as the body of
SQRT would be provided (via a subroutine library, in many cases) by most FORTRAN
compilers.

The only definitions supplied by the user in this case, other than the lines
shown above, are "n" and "type", which refer to the value to be formatted and
its type, respectively.

Assuming that a generic package supplied by the compiler does not meet your
definition of a "language primitive," what's the relevance of this to the lines
you quoted? Is there a language design philosophy for PL/I that says "language 
primitives" should be very terse? Is this in the standard somewhere?

> Or are you saying that PayRoll is also built into the language (and
> implemented in a single statement)?

Since I don't know to what "PayRoll" you are referring, I certainly would
not claim it is part of the Ada language (or any other language :). I would
say something is "built into" the language if it is defined by the language
specification. For Ada.Text_IO.Editing.Decimal_Output, this is the case. See

  http://www.adahome.com/rm95/rm9x-F-03.html

"Edited Output for Decimal Types," in the on-line version of the Ada standard.

(By the way, is there an equivalent on-line version of the ISO PL/I standard?)

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




^ permalink raw reply	[relevance 4%]

* Re: Leading zeros with Int_IO.Put()? Or another package?
  1996-11-22  0:00  3%             ` Ken Garlington
@ 1996-11-27  0:00  4%               ` Verne Arase
  1996-12-02  0:00  4%                 ` Ken Garlington
  0 siblings, 1 reply; 21+ results
From: Verne Arase @ 1996-11-27  0:00 UTC (permalink / raw)



In article <3295F2A9.1EF0@lmtas.lmco.com>,
Ken Garlington <garlingtonke@lmtas.lmco.com> wrote:

 >  use Ada.Text_IO.Editing;
 >  ...
 >  package Edited_IO is new Decimal_Output (type);
 >  ...
 >  Edited_IO.Put (n, To_Picture ("-99999999"));
 >
 >Interesting. They look reasonably similar to me. If anything,
 >the Ada version makes it clear from the text that this
 >I/O is using the Picture feature of the language. However,
 >if you believe "P" is more readable in this regard, I
 >suppose we'll have to agree to disagree...

Well, we are talking about a langugage primative rather than a subroutine
library.

Or are you saying that PayRoll is also built into the language (and
implemented in a single statement)?

---
The above are my own opinions, and not those of my employer.




^ permalink raw reply	[relevance 4%]

* Re: Leading zeros with Int_IO.Put()? Or another package?
    1996-11-20  0:00  3%             ` Richard A. O'Keefe
@ 1996-11-22  0:00  3%             ` Ken Garlington
  1996-11-27  0:00  4%               ` Verne Arase
  1 sibling, 1 reply; 21+ results
From: Ken Garlington @ 1996-11-22  0:00 UTC (permalink / raw)



robin wrote:
> Ken Garlington <garlingtonke@lmtas.lmco.com> writes:
> 
>         >"The need for languages that promote reliability and simplify maintenance
>         >is well established. Hence emphasis was placed on program readability over
>         >ease of writing."
> 
> Ada clearly failed in this aspect.

Hmmm. So you consider the syntax

  put edit (n) (P'-99999999');

more readable than the Ada equivalent

  use Ada.Text_IO.Editing;
  ...
  package Edited_IO is new Decimal_Output (type);
  ...
  Edited_IO.Put (n, To_Picture ("-99999999"));

Interesting. They look reasonably similar to me. If anything,
the Ada version makes it clear from the text that this
I/O is using the Picture feature of the language. However,
if you believe "P" is more readable in this regard, I
suppose we'll have to agree to disagree...

>         >Of course, once you have the zero-fill package (or whatever
>         >other abstraction you intend to reuse), the number of lines
>         >you have to write drops quite a bit.
> 
> No excuse for having everyone who wants to use such a facility
> to have to write it.

1. Why does everyone have to rewrite publicly-available code? I usually
just reuse it. (Perhaps this is an Ada-unique mindset.)

2. The equivalent of your code is directly available in Ada, if
desired (see above).

> It is, after all, avalable ina number of languages including COBOL
> and PL/I.
> 
> The simplicity and usefulness of PL/I in producing
> zero suppression/insertion of characters/general editing/
> in a variety of forms (integer, fixed-point, floating-point) and suitable
> for business and science cannot be refuted.
> 
> As I indicated earlier, just one short line will suffice! :
> 
> put edit (d) (P'999.V999');

What I don't understand is, given the statement above, how I can
restrict the use of the statement above so that "d" is always a
numeric value in the range 0.000 .. 999.999. Implicit strong
typing is available in a number of languages, including Ada, so
there's no excuse for having everyone who wants to use such a
facility to have to write it explicitly. Perhaps you could post
the PL/I solution so that I could compare it to the Ada version.

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




^ permalink raw reply	[relevance 3%]

* Re: Leading zeros with Int_IO.Put()? Or another package?
  1996-11-20  0:00  3%             ` Richard A. O'Keefe
@ 1996-11-20  0:00  3%               ` robin
  0 siblings, 0 replies; 21+ results
From: robin @ 1996-11-20  0:00 UTC (permalink / raw)



ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:

	>rav@goanna.cs.rmit.edu.au (robin) writes:

	>>Ken Garlington <garlingtonke@lmtas.lmco.com> writes:
	>>	>From the Introduction section of ISO/IEC 8652:1995:

	>>	>"The need for languages that promote reliability and simplify maintenance
	>>	>is well established. Hence emphasis was placed on program readability over
	>>	>ease of writing."

	>>Ada clearly failed in this aspect.

	>This is not clear at all.

---It is abundantly clear that it failed as to ease of writing.
Various postings suggested that the conversion could be done in up to
82 lines of Ada code, whereas PL/I requires one simple line.

	>I have used a great many programming languages,

Haven't we all!

	>and find Ada to be _dramatically_ more readable (in terms of
	>how well I can read other people's code) than most of them.
	>It beats C and C++ by a country mile,

On this we agree.

	>and I find that it beats PL/I as well.

On this we don't.

	>One of the reasons is that conversions are explicit.

	>>No excuse for having everyone who wants to use such a facility
	>>to have to write it.

	>*BUT THEY DON'T*.

But they do, and there were various postings all giving different
ways to accomplish it in Ada.

	>It is a common rhetorical device of yours, rav, to take a
	>true statement "someone must write X", and use the _false_
	>statement "everyone must write X" as a stick to beat Ada with.

	>>It is, after all, avalable in a number of languages including COBOL
	>>and PL/I.

	>We are specifically talking about converting numbers to text.
	>If you want a list of languages with such features,
	>add Burroughs Extended Algol, and Algol 68.

Those (COBOL and PL/I) were only examples.  Even BASIC has it.

	>Also add Ada 95.

Only if it's implemented.

	>We have GNAT, and the current GNAT documentation says all
	>the annexes are supported.
	>I _have_ tried picture editing in GNAT; it works fine, and it
	>is no harder and no easier to write Ada pictures than COBOL
	>or PL/I pictures.

Only where Ada supports a CoBOL or PL/I equivalent, as you
admit below.

	>>The simplicity and usefulness of PL/I in producing
	>>zero suppression/insertion of characters/general editing/
	>>in a variety of forms (integer, fixed-point, floating-point) and suitable
	>>for business and science cannot be refuted.

	>Can I refute the usefulness of PL/I for this?
	>I cannot, and would not want to.
	>Can I refute the simplicity of PL/I for this?
	>Well, it depends on what you you mean.
	>As noted above, I don't find it any harder to write
	>Ada pictures than PL/I pictures, and I welcome the
	>level of detail in the ADA 95 LRM.
	>I've used pictures in Burroughs Algol, COBOL, and PL/I, and
	>the devil is in the details.
	>Concerning the actual _use_ of pictures, if you use named
	>pictures in PL/I, there is very little to chose.

There is considerable difference -- in favor of PL/I -- between the
two.  After all, you have demonstrated it!

	>If you
	>_don't_ use named pictures (by which I mean ones declared
	>in a PL/I DECLARE statement or an Ada object declaration)
	>then using "magic strings" is just as bad as using "magic
	>numbers".

???????
Now why would you bury a picture specification in a remote place from 
the output statement that uses it?

	>>As I indicated earlier, just one short line will suffice! :

	>>put edit (d) (P'999.V999');

	>I note that Ada 95 pictures offer some features missing from COBOL-85
	>and that they're pretty useful.

	>I note that Ada 95 makes it pretty easy to read a picture from a file,
	>or compute on on the fly by some other method.

A facility that's available in IBM's PL/I for OS/2, Windows 95/NT and
AIX.

	>In particular, from
	>the attributes of "d" in an example like this.)

	>I willingly concede that it is a nuisance that Ada 95 pictures apply to
	>decimal fixed point numbers, not integers or floating point numbers.
	>(In particular, Ada 95 pictures have no "exponent picture" support.)
	>I also willingly concede that waiting until run time to check pictures
	>whose strings are known at compile time is not what I would have chosen.

	>In the case of writing out integers with pictures,
	>I don't greatly mind having

	>	type Decimal_Integer is delta 1.0 digits 9;
	>	package Decimal_Integer_Editing is new
	>	   Ada.Text_IO.Editing.Decimal_Output(Decimal_Integer);
	>	use Decimal_Integer_Editing;

	>ONCE somewhere in a program (probably written by someone else) and
	>then doing
	>	Put(Decimal_Integer(X), To_Picture("-999_999_999"));
	>or whatever.  

Thank you for proving the point!  PL/I's

   put edit (d) (P'-999,999,999');

is a lot simpler. What's more, you don't have to hunting for
Decimal_Integer to find out what it does.

P.S. Check out PL/I's drifting user-specifiable currency symbols etc
for picture editing.  Great fun!

	>Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.




^ permalink raw reply	[relevance 3%]

* Re: Leading zeros with Int_IO.Put()? Or another package?
  @ 1996-11-20  0:00  3%             ` Richard A. O'Keefe
  1996-11-20  0:00  3%               ` robin
  1996-11-22  0:00  3%             ` Ken Garlington
  1 sibling, 1 reply; 21+ results
From: Richard A. O'Keefe @ 1996-11-20  0:00 UTC (permalink / raw)



rav@goanna.cs.rmit.edu.au (robin) writes:

>Ken Garlington <garlingtonke@lmtas.lmco.com> writes:
>	>From the Introduction section of ISO/IEC 8652:1995:

>	>"The need for languages that promote reliability and simplify maintenance
>	>is well established. Hence emphasis was placed on program readability over
>	>ease of writing."

>Ada clearly failed in this aspect.

This is not clear at all.
I have used a great many programming languages,
and find Ada to be _dramatically_ more readable (in terms of
how well I can read other people's code) than most of them.
It beats C and C++ by a country mile,
and I find that it beats PL/I as well.
One of the reasons is that conversions are explicit.

>No excuse for having everyone who wants to use such a facility
>to have to write it.

*BUT THEY DON'T*.

It is a common rhetorical device of yours, rav, to take a
true statement "someone must write X", and use the _false_
statement "everyone must write X" as a stick to beat Ada with.

>It is, after all, avalable ina number of languages including COBOL
>and PL/I.

We are specifically talking about converting numbers to text.
If you want a list of languages with such features,
add Burroughs Extended Algol, and Algol 68.
Also add Ada 95.

Have you looked at Annex F in the Ada 95 LRM?
It's on-line here, and quite a few staff members have printed copies.
Have you _tried_ the Annex F stuff?
We have GNAT, and the current GNAT documentation says all
the annexes are supported.
I _have_ tried picture editing in GNAT; it works fine, and it
is no harder and no easier to write Ada pictures than COBOL
or PL/I pictures.

>The simplicity and usefulness of PL/I in producing
>zero suppression/insertion of characters/general editing/
>in a variety of forms (integer, fixed-point, floating-point) and suitable
>for business and science cannot be refuted.

Can I refute the usefulness of PL/I for this?
I cannot, and would not want to.
Can I refute the simplicity of PL/I for this?
Well, it depends on what you you mean.
As noted above, I don't find it any harder to write
Ada pictures than PL/I pictures, and I welcome the
level of detail in the ADA 95 LRM.
I've used pictures in Burroughs Algol, COBOL, and PL/I, and
the devil is in the details.
Concerning the actual _use_ of pictures, if you use named
pictures in PL/I, there is very little to chose.  If you
_don't_ use named pictures (by which I mean ones declared
in a PL/I DECLARE statement or an Ada object declaration)
then using "magic strings" is just as bad as using "magic
numbers".

>As I indicated earlier, just one short line will suffice! :

>put edit (d) (P'999.V999');

I note that Ada 95 pictures offer some features missing from COBOL-85
and that they're pretty useful.

I note that Ada 95 makes it pretty easy to read a picture from a file,
or compute on on the fly by some other method.  (In particular, from
the attributes of "d" in an example like this.)

I willingly concede that it is a nuisance that Ada 95 pictures apply to
decimal fixed point numbers, not integers or floating point numbers.
(In particular, Ada 95 pictures have no "exponent picture" support.)
I also willingly concede that waiting until run time to check pictures
whose strings are known at compile time is not what I would have chosen.

In the case of writing out integers with pictures,
I don't greatly mind having

	type Decimal_Integer is delta 1.0 digits 9;
	package Decimal_Integer_Editing is new
	   Ada.Text_IO.Editing.Decimal_Output(Decimal_Integer);
	use Decimal_Integer_Editing;

ONCE somewhere in a program (probably written by someone else) and
then doing

	Put(Decimal_Integer(X), To_Picture("-999_999_999"));

or whatever.  

-- 
Mixed Member Proportional---a *great* way to vote!
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.




^ permalink raw reply	[relevance 3%]

* Re: Leading zeros with Int_IO.Put()?  Or another package?
  @ 1996-11-08  0:00  5%   ` Norman H. Cohen
  0 siblings, 0 replies; 21+ results
From: Norman H. Cohen @ 1996-11-08  0:00 UTC (permalink / raw)



Robert I. Eachus wrote:


> ... 2) In Ada 95 look at Annex F.  

Good idea, this is certainly an appropriate application of
picture-directed output.  If your compiler supports the Information
Systems annex, you can write:

   with Ada.Text_IO.Editing; 
   use Ada.Text_IO, Ada.Text_IO.Editing;

   procedure Put_Time (Hours, Minutes, Seconds: in Integer) is
      type Time_Component_Type is
         delta 1.0 digits 2 range 0.0 .. 60.0;
      package Time_Component_Output is
         new Decimal_Output (Time_Component_Type);
      use Time_Component_Output;
      Leading_Zero  : constant Picture := To_Picture ("99");
      Leading_Space : constant Picture := To_Picture ("Z9");
   begin
      Put (Time_Component_Type(Hours), Leading_Space);
      Put (':');
      Put (Time_Component_Type(Minutes), Leading_Zero);
      Put (':');
      Put (Time_Component_Type(Seconds), Leading_Zero);
   end Put_Time;

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




^ permalink raw reply	[relevance 5%]

* Re: Leading zeros with Int_IO.Put()? Or another package?
    @ 1996-11-08  0:00  4%     ` Ken Garlington
  1 sibling, 0 replies; 21+ results
From: Ken Garlington @ 1996-11-08  0:00 UTC (permalink / raw)



robin wrote:
> 
>         David Shochat <shochat@itg-sepg.logicon.com> writes:
> 
>         >J.D. Baldwin wrote:
> 
>         >> My question:  is there a better way to pad out integers with leading
>         >> zeros?
> 
>         >Whenever I need leading zeros (in any radix), I use what we call here
>         >the "Everage Maneuver" (named after fellow Logiconer Amy Everage, who
>         >came up with this years ago). Lets say we want to put the nonnegative
>         >integer n to a field of k characters with radix r using leading zeros if
>         >necessary. So we assert n < r**k.
>         >1. Convert n + r**k to a string. This uses k+1 characters, the 1st of
>         >which is '1', representing r**k.
>         >2. Use all but the 1st character from the result of (1).
> 
> 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'

Or, if you use a decimal type, you can just use Ada:

  package Pic_IO is new Ada.Text_IO.Editing.Decimal_Output(<some decimal type>);
  ...
  Pic_IO.Put (n, Pic_IO.To_Picture("-99999999")); -- or "-999,999,999", etc.

See ISO/IEC 8652:1995 F.3 (Edited Output for Decimal Types).

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




^ permalink raw reply	[relevance 4%]

Results 1-21 of 21 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
1996-11-05  0:00     Leading zeros with Int_IO.Put()? Or another package? J.D. Baldwin
1996-11-05  0:00     ` David Shochat
1996-11-08  0:00       ` robin
1996-11-08  0:00         ` Robert Dewar
1996-11-13  0:00           ` robin
1996-11-13  0:00             ` Ken Garlington
1996-11-19  0:00               ` robin
1996-11-20  0:00  3%             ` Richard A. O'Keefe
1996-11-20  0:00  3%               ` robin
1996-11-22  0:00  3%             ` Ken Garlington
1996-11-27  0:00  4%               ` Verne Arase
1996-12-02  0:00  4%                 ` Ken Garlington
1996-11-08  0:00  4%     ` Ken Garlington
1996-11-06  0:00     ` Robert I. Eachus
1996-11-08  0:00  5%   ` Norman H. Cohen
1997-09-01  0:00     Newbie Q: Zero fill in Put Larry Coon
1997-09-02  0:00     ` Jacob Sparre Andersen
1997-09-05  0:00  4%   ` Robert Dewar
1997-09-03  0:00  6% ` Pascal Obry
1997-09-04  0:00  4% ` Robert Dewar
1999-01-12  0:00     Ada vs C++ vs Java Leszek Sczaniecki
1999-01-13  0:00     ` Erik Funkenbusch
1999-01-14  0:00       ` Gerhard Menzl
1999-01-14  0:00         ` John Birch
1999-01-14  0:00           ` Pat Rogers
1999-01-16  0:00             ` John Birch
1999-01-17  0:00               ` Matthew Heaney
1999-01-17  0:00                 ` Mike Coffin
1999-01-17  0:00                   ` Matthew Heaney
1999-01-17  0:00                     ` Mike Coffin
1999-01-17  0:00                       ` Matthew Heaney
1999-01-17  0:00                         ` Mike Coffin
1999-01-22  0:00                           ` Matthew Heaney
1999-01-22  0:00  4%                         ` adam
2000-03-04  0:00     I18N gettext style tmoran
2000-03-05  0:00  6% ` tmoran
2000-04-17  0:00     integer'image NANCY HEHIR
2000-04-17  0:00     ` integer'image Ted Dennison
2000-04-18  0:00       ` integer'image Marin D. Condic
2000-04-18  0:00         ` integer'image Ted Dennison
2000-04-18  0:00  4%       ` integer'image Marin D. Condic
2002-07-17  2:53     Floating Decimal Package/Library? Robert C. Leif
2002-07-17  4:41  7% ` tmoran
2002-07-17 16:30  0%   ` Warren W. Gay VE3WWG
2003-07-09  4:42     How to debug an Ada program mauricio
2003-07-09 16:07     ` Pascal Obry
2003-07-11 13:05       ` Debugger Rant (was Re: How to debug an Ada program) Marc A. Criley
2003-07-11 15:13         ` Jerry Petrey
2003-07-11 18:42  5%       ` Robert I. Eachus
2006-11-08 20:53     Regular Expressions in Ada 2005? matthias.kistler
2006-11-08 21:14  4% ` Georg Bauhaus
2007-06-14 13:07     Predefined Packages anon
2007-06-14 13:41     ` Ludovic Brenta
2007-06-14 19:58  4%   ` Randy Brukardt
2008-07-26 23:59     Ada Function for logMsg or printf richtmyer
2008-07-27  5:47     ` tmoran
2008-07-27 11:33       ` richtmyer
2008-07-27 21:46         ` Fionn Mac Cumhaill
2008-07-28  7:52           ` Markus Schoepflin
2008-07-31 10:35             ` richtmyer
2008-07-31 10:44  4%           ` Georg Bauhaus
2010-06-03  2:59     Ada noob here! Is Ada widely used? Yannick Duchêne (Hibou57)
2010-06-04 19:23     ` Fritz Wuehler
2010-06-05  7:47  4%   ` Georg Bauhaus
2010-06-05 22:43  0%     ` starwars

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