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: 103376,9ce828272f314121 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!nntp.idg.pl!wsisiz.edu.pl!news2.icm.edu.pl!not-for-mail From: "Staszek Goldstein" Newsgroups: comp.lang.ada Subject: Re: output of enumeration types Date: Wed, 20 Apr 2005 02:17:26 +0200 Organization: http://news.icm.edu.pl/ Message-ID: References: NNTP-Posting-Host: systemy230.toya.net.pl X-Trace: achot.icm.edu.pl 1113956240 1994 217.113.225.230 (20 Apr 2005 00:17:20 GMT) X-Complaints-To: abuse@icm.edu.pl NNTP-Posting-Date: Wed, 20 Apr 2005 00:17:20 +0000 (UTC) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Priority: 3 X-RFC2646: Format=Flowed; Original X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MSMail-Priority: Normal Xref: g2news1.google.com comp.lang.ada:10596 Date: 2005-04-20T02:17:26+02:00 List-Id: Uzytkownik "Stephen Leake" napisal w wiadomosci news:mailman.54.1113954069.24457.comp.lang.ada@ada-france.org... > "Staszek Goldstein" writes: > >> This > > please quote enough so we can tell what you are refering to. My letter was an answer to a specific message containing just one idea. >> is also a nice idea, although for converting a string you still need >> a function like the one given by Stephen Leake. It seems to me that >> it should be possible to output the roman number as easily as it is >> to output a string - there is no difference between the literals, >> they both look exactly the same. > > 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. > 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. Staszek