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,9ce828272f314121 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!news-FFM2.ecrc.net!noris.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: output of enumeration types Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Wed, 20 Apr 2005 11:53:38 +0200 Message-ID: NNTP-Posting-Date: 20 Apr 2005 11:53:41 MEST NNTP-Posting-Host: 6c77d919.newsread2.arcor-online.net X-Trace: DXC=B=:kKo4BkBGUo1RUcdhQmEQ5U85hF6f;DjW\KbG]kaMH:cmYYm_h3\CM3eMe_?AHeLWRXZ37ga[7Jn919Q4_`VjIB8=X\UUgbkD X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:10607 Date: 2005-04-20T11:53:41+02:00 List-Id: On Wed, 20 Apr 2005 02:17:26 +0200, Staszek Goldstein wrote: > Uzytkownik "Stephen Leake" napisal w wiadomosci > news:mailman.54.1113954069.24457.comp.lang.ada@ada-france.org... >> As far as I can see, it is "just as easy". There is a package, that >> someone wrote, that does text output for type String. Since you are >> writing a new type, you need to write the output package for that as >> well. Once that is done, both are "just as easy" for anyone else to >> use. >> >> Note that Character has a special place in this discussion, since by >> definition it is what gets written to a "text" file. >> >> So to do "output" with Roman_Number, you must specify some way to >> convert its components to Character. > > I do not feel convinced by the argument. If you want to write a number, you > can qualify it > to be of some specific type and output it using, say, some instantiation of > the > ada.text_io.integer_io package. Although the situation is very similar > here - I just want to be > able to output character literals or arrays of such literals, I have no > generic package at > my disposal and no possibility of converting them directly to the > "character" or "string" type. What you refer are remnants of Ada 83 [flawed] approach which hopefully someday will be replaced in a more OO way, where 'Image would become object's attribute, dispatching and thus requiring no type specification in any form. Note that generic instantiation (of Integer_IO etc) is a sort of type specification. >> Here's another tidbit that points out why "universal character" wont >> solve this problem: >> >> type Roman_Digit is (Foo,'V','X','L','C','D','M'); >> >> is a perfectly legal type declaration! > > I am not sure if this is really a problem. If 'V' is of a "universal > character type", then it is directly > convertible to any character type which contains it as an enumeration > literal. Also, writing > character(rm), where rm is a roman digit, should do no harm - this should > raise constraint_error > or program_error if rm is not a character literal. More or less the same is > true of > integer(long_int)... By the way, I have not experienced many applications of > the "mixed" types > up to now. Universal character as a common ancestor for all character type is a good idea, but as Stephen has pointed out, it would not solve this particular problem. You need a way to convey that Roman_Digit is a character type derived from universal character. Presently Ada does not have character class. Neither you can create a subtype of Character non-contiguous ranges of characters (BTW, character maps might be what you are looking for.) Further you'll need universal strings and the string class, also useful, but non-existent in Ada. Too much work. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de