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=2.1 required=5.0 tests=BAYES_05,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!rutabaga.cis.ohio-state.edu!edwards From: edwards@rutabaga.cis.ohio-state.edu (stephen edwards) Newsgroups: comp.lang.ada Subject: Re: integer'image Message-ID: <87789@tut.cis.ohio-state.edu> Date: 29 Jan 91 19:55:37 GMT References: <2390@shodha.enet.dec.com> <2638@sparko.gwu.edu> <557.27a476f2@vger.nsu.edu> Sender: news@tut.cis.ohio-state.edu Reply-To: stephen edwards Organization: Ohio State University Computer and Information Science List-Id: In article <557.27a476f2@vger.nsu.edu> g_harrison@vger.nsu.edu ((George C. Harrison) Norfolk State University) writes: [ ... stuff about INTEGER'IMAGE deleted ... ] > >The problem really is the formatting of enumerated elements, integers, and >[ideally] floats in the middle of string expressions. > >I am tired of writing > >PUT("The temperature at the"); >MYINTEGER_IO.PUT(N,5); >PUT(" hour is"); >MYFLOAT_IO.PUT(TEMPERATURE,7,2); >PUT(" "); >MYTEMPERATURE_TYPE_IO.PUT(FAHRENHEIT); >NEW_LINE; > Well, believe it or not, there are very trivial ways to do this easily. Imagine being able to write the following magical expression: Put_Line("The temperature at the " & N & " hour is " & TEMPERATURE & " " & FAHRENHEIT); Well, you can do this easily in Ada, albeit with the addition of a few function definitions over and above those provided in Text_IO. Of course, you can wrap those in packages (generic ones, even) to use them over and over--so you'll never have to write horrible, complicated output expressions again! :-) :-) :-) Of course, those who hate overloading or _use_ clauses, especially if they are used together, will jump all over you. However, it seems the code is much more readable in the above example (not to mention easier to write, and easier to maintain). There _are_ times when these capabilities can be very useful. Also notice that none of these facilities require any changes to the current Text_IO spec or implementation. All can be layered right on top of the existing package in a completely portable manner. Note: actual definitions for the various instances of "&" in the above example are left as an exercise for the reader. For extra credit, think about how one would extend such definitions to support the extra formatting a fully general system might support (e.g., MyInteger_IO.Put(n,5); ... MyFloat_IO.Put(temperature, 7, 2); ... etc., in the current Text_IO). -- Steve Stephen Edwards U.S. mail: 372 Jones Tower e-mail : edwards@cis.ohio-state.edu 101 Curl Drive home phone: (614)-293-0842 Columbus, OH 43210