From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,75c440b4b7ed5f91 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Real Time IO routines answering Simon Wright part 2 Reply-To: anon@anon.org (anon) References: <1193410739.367181.96050@50g2000hsm.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Tue, 30 Oct 2007 16:35:03 GMT NNTP-Posting-Host: 12.65.102.56 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1193762103 12.65.102.56 (Tue, 30 Oct 2007 16:35:03 GMT) NNTP-Posting-Date: Tue, 30 Oct 2007 16:35:03 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:2647 Date: 2007-10-30T16:35:03+00:00 List-Id: -- -- This is Part 2. A simpler version of an Ada purist type of -- answer to the original thread poster question. Also ths -- version should answer "Dmitry A. Kazakov" concerns about -- types being defined in private. The RM does have its view on -- this version. -- -- -- Where did I get the information that IMAGE should be use for -- debugging only? A few Ada conferences back in the early to -- mid 1990's dealing with Ada programming and debugging -- techniques. And is fully embrased by Adacore aka creaters of -- GNAT. -- -- -- z.adb -- -- -- Compile with "-gnatwI" or you may receive Portable and Version -- Warnings, for the sub package "ada.real_time.io" aka user-written -- child of "ada.real_time". (GNAT) -- with Ada.Real_Time ; with Ada.Real_Time.IO ; -- programmer Ada extension package with Ada.Text_IO ; use Ada.Real_Time ; use Ada.Text_IO ; procedure z is Time_Value : Time ; begin Time_Value := Clock ; Put ( "Time := " ) ; Ada.Real_Time.IO.Put ( Time_Value ) ; New_Line ; end z ; -- -- a-retiio.ads -- -- Package must be included with program source code, do to -- the "non-Portable" nature of this code. -- package Ada.Real_Time.IO is -- -- Put: Uses the default Put routine. To keep this example -- simple the routines uses the type default for -- formatting -- procedure Put ( Z : Time ) ; end Ada.Real_Time.IO ; -- -- a-retiio.adb => Ada Standard Extension Package. -- pragma Style_Checks (OFF); -- not needed if you use GNAT style -- requirements aka rules for spacing -- -- Gnat will view this package as a "Language Defined Unit" even -- though it is not in the Standard GNAT package list. -- -- Package must be included with program source code, do to -- the "non-Portable" nature of this code. -- -- ------------------------------------------------------- -- -- An Ada Purist would have bypassed using a package -- -- routine and added a local routine for printing the -- -- "Time" value directly to a text file. That way they -- -- could reduce the code to the bare bones. -- -- ------------------------------------------------------- -- -- I used a generic package because it was faster and -- -- easier to generate the example of an extension to -- -- the Standard Ada packages. -- -- ------------------------------------------------------- -- with Ada.Text_IO ; package body Ada.Real_Time.IO is -- -- Time specification comes from the parent's code. -- package D_IO is new Ada.Text_IO.Fixed_IO ( Time ) ; -- -- Put: Uses the default Put routine. To keep this example -- simple the routines uses the type default for -- formatting -- procedure Put ( Z : Time ) is begin -- Put D_IO.Put ( Z ) ; end Put ; end Ada.Real_Time.IO ; In , Simon Wright writes: >anon@anon.org (anon) writes: > >> Ada Purist never and I mean NEVER uses IMAGE attribute, in the body of >> a program. They create a package or sub-package that performs the IO >> functions with the use of the IMAGE attribute. >> >> IMAGE attribute is the last thing a programmer should use. to print a value. >> It is normally use for DEBUGGING ONLY! A programmer should always create >> a routine or better yet a package that uses an algorithm to prints the value >> without the use of attributes. >> >> Mostly programs that are created by newbees use IMAGE attribute. > >I must be a newbie (NB spelling!) then. > >Where on earth do you get this viewpoint from? Please say why it is >better to instantiate enumeration IO for Boolean rather than to use >Boolean'Image? > >I suppose you would ban people from using Integer_IO, too. Good grief. > >> And as for my code! It answer the person question without adding extra >> code that might confuse him. Plus, the "Ada.Real_Time" package uses: >> >> type Time is new Duration; >> >> which is in private section. So I know what to convert the value to. > >This is true so long as you and the person to whom you are giving >advice are both using *this version of* *GNAT*. Whatever makes you >suppose that the code you see in that private part will be the same >for any other compiler? or for any other version of GNAT? or for GNAT >for a different platform?