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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c689b55786a9f2bd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 07 May 2010 10:53:14 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: for S'Image use Func?? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4be3d4fb$0$7651$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 07 May 2010 10:53:15 CEST NNTP-Posting-Host: adee91d4.newsspool1.arcor-online.net X-Trace: DXC=W^kZDU`YKihJR;B_cic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbD>=kX2P@_efPCY\c7>ejVhSfm6I2R`aXl=J2G6he06ak X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:11358 Date: 2010-05-07T10:53:15+02:00 List-Id: On 5/6/10 7:10 PM, Warren wrote: > Finally, there is actually a third question- more along > the lines of "Should this language feature be used > in this manner?", or is it preferable to just code your > own along the lines of (which is what I presently use): Apologies for the length of the following. In short: not in this manner, use Ada instead, don't tweak the language, no need. [1. mislead assumptions]. If, as Bob has said, programmers discover 'Image before they discover Text_IO.*_IO and Text_IO.Editing, then there is something wrong, indeed---with Ada's appearance before them! If you want them to be able to write an output line quickly, give them a package! Don't misuse 'Image. They may be quite used to industry standard logging packages and such, no hurdle there. [2. 'Image *and* 'Value are paired and have a purpose, or contract]. Is 'Image a formatting function? I don't think so. Is it intended to be one? I can't imagine that, not in any non-trivial sense of the word "formatting". 'Value is its counter part. Is it a scanning function? I don't think that, either, for the same reason. And if 'Image and 'Value come in pairs, redefining one without the other seems wrong. So what should a user- defined 'Value be? Shouldn't it agree with what the LRM implies? Should not the new Generic_Dispatching_Constructor be its equivalent? Should we, in spite of all this, deprive ourselves of what we routinely do in other cases? That is, ideally we express the purpose of a function call with suitably and freely chosen names for an implementation that meets our needs. You said you were too lazy to ... and therefore wanted to adapt something half related to your purpose. You might be doing yourself (and your readers) a disservice. To see this: What is the contract if 'Image, expressed as pre- and post-conditions? What could this description be in the standard if programmers we invited to dismiss printing packages in favor of user defined 'Image, thereby manipulating the contract of 'Image? [3. Use normal Ada for polymorphism]. If I wanted polymorphic behavior of numbers, I'd make them have a suitable type. Or wrap them in one where necessary, e.g. during I/O. Or mix them with a package that provides "polymorphic appearance" like Dmitry's or, IIUC, PragmAda. You can say type Derived_Num_Type is new ; overriding function Image (X: Derived_Num_Type) return String; where Derived_Num_Type is both tag-less and has an Image operation that makes strings the way you want them. [4. no need]. Why do Ada programmers forget Ada language principles whenever it comes to basic values? :o( Is it not obvious that using 'Image in ways it was not intended to be used makes the program text misleading? I can understand that the customer is always right and that Ada vendors would quite naturally consider tweaking 'Image. But I also hope they have ways to provide alternatives based on existing Ada that will serve both their customers and Ada. Certainly you know what your image functions should do. So write them. -- Georg