comp.lang.ada
 help / color / mirror / Atom feed
From: "Samuel T. Harris" <sam_harris@hso.link.com>
Subject: Re: Printing Enum Variable Re: Linux World
Date: 1999/03/03
Date: 1999-03-03T00:00:00+00:00	[thread overview]
Message-ID: <36DDD621.6FDE496B@hso.link.com> (raw)
In-Reply-To: 36DDA761.7B4E8099@aasaa.ofe.org

David Starner wrote:
> 
> fraser@synopsys.ha.com wrote:
> >
> > I nearly cried when dstarner98@aasaa.ofe.org said:
> >
> > [ printing enumerations in C example deleted ...]
> >
> > The point being, of course, that in Ada I write:
> >
> >    Bob'Image (X)
> >
> > which still works even if I add an apricot.  Which solution do you prefer?

When I don't like the case of 'image, I use enumeration_io which
provides control over case. When I don't like the other stuff,
then I use a constant array indexed by the enumeration type
with component type of access to string. Who needs a case or switch
statement?
Oh, and the compiler complains when I add an apricot but forget
to add the additional component to my constant array initialization
aggregate. Oh yeah, I almost forgot about those nasty Ada reserved
words colliding with my intended vocabulary. In that case, I
instantiate my own word_io package which deals with the arbitrary
prefixes I had to use for x_all (the most common collision in
my experience). It not only duplicates the functionality of
enumeration_io, but also provides the width, image, and value
functions which correspond to the attributes so my resulting
code looks reasonably similar to what I wanted in the first place.

> 
> Mine. For my example printed out "Red apple" as opposed to "RED_APPLE",
> and could be quickly internationalized. The only way to internationalize
> Bob'Image (X) is to rip it out and replace all examples with something
> like the code you cut. I don't think direct outputing of enumerations is
> right except as a quick and dirty hack - the name mangling require by C
> or Ada (no spaces, no hypens, etc.) combined with the i18n problems make
> it inappropriate.

> 
> I never meant this as an attack on Ada. It just that complaining about C
> for lack of enumeration strings is as appropriate as complaining about
> Ada for lack of a "?:" operator. It's not that big a deal.
> --
> David Starner - OSU student - dstarner98@aasaa.ofe.org
> If you want a real optimist, look up Ray Bradbury. Guy's nuts.
> He actually likes people. -David Brin

-- 
Samuel T. Harris, Principal Engineer
Raytheon, Scientific and Technical Systems
"If you can make it, We can fake it!"




  parent reply	other threads:[~1999-03-03  0:00 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-02  0:00 Linux World Richard D Riehle
1999-03-02  0:00 ` fraser
1999-03-02  0:00   ` Printing Enum Variable " David Starner
1999-03-03  0:00     ` Larry Kilgallen
1999-03-03  0:00       ` Nick Roberts
1999-03-03  0:00         ` David Starner
1999-03-03  0:00     ` Fraser Wilson
1999-03-03  0:00       ` David Starner
1999-03-04  0:00         ` Richard D Riehle
1999-03-04  0:00         ` robert_dewar
1999-03-04  0:00         ` Richard D Riehle
1999-03-04  0:00         ` Magnus Larsson
1999-03-03  0:00           ` Hans Marqvardsen
1999-03-04  0:00             ` robert_dewar
1999-03-04  0:00               ` Hans Marqvardsen
1999-03-05  0:00                 ` dewar
1999-03-07  0:00                   ` Hans Marqvardsen
1999-03-04  0:00               ` Hans Marqvardsen
1999-03-05  0:00                 ` dewar
1999-03-05  0:00                   ` David Botton
1999-03-05  0:00                     ` robert_dewar
1999-03-05  0:00                 ` Larry Kilgallen
1999-03-04  0:00             ` Nick Roberts
1999-03-03  0:00           ` Printing Enum Variable Re: Linux World (Correction) Hans Marqvardsen
1999-03-04  0:00         ` Printing Enum Variable Re: Linux World fraser
1999-03-05  0:00           ` Nick Roberts
1999-03-05  0:00             ` fraser
1999-03-03  0:00     ` fraser
1999-03-03  0:00       ` David Starner
1999-03-03  0:00         ` fraser
1999-03-03  0:00         ` Samuel T. Harris [this message]
1999-03-04  0:00         ` robert_dewar
1999-03-03  0:00           ` David Starner
1999-03-04  0:00             ` Samuel Mize
1999-03-04  0:00               ` Samuel Mize
1999-03-05  0:00                 ` Robert A Duff
1999-03-05  0:00               ` Robert A Duff
1999-03-07  0:00               ` Florian Weimer
1999-03-07  0:00                 ` Michael Young
1999-03-07  0:00                   ` Larry Kilgallen
1999-03-07  0:00                     ` Michael Young
1999-03-08  0:00                       ` Florian Weimer
1999-03-08  0:00                       ` Larry Kilgallen
1999-03-08  0:00                         ` robert_dewar
1999-03-08  0:00                       ` robert_dewar
1999-03-08  0:00                         ` Richard D Riehle
1999-03-09  0:00                           ` Michael Young
1999-03-09  0:00                             ` Larry Kilgallen
1999-03-09  0:00                               ` billy
1999-03-10  0:00                                 ` robert_dewar
1999-03-10  0:00                                   ` Dale Stanbrough
1999-03-10  0:00                                     ` dennison
1999-03-10  0:00                                       ` bob
1999-03-10  0:00                                         ` Mike Silva
1999-03-10  0:00                                           ` dennison
1999-03-10  0:00                                           ` Nick Roberts
1999-03-10  0:00                                     ` Pascal Obry
1999-03-10  0:00                                     ` Richard D Riehle
1999-03-10  0:00                                 ` Pascal Obry
1999-03-09  0:00                               ` Michael Young
1999-03-10  0:00                                 ` Mike Silva
     [not found]                               ` <7c4ru6$e45$1@remarq.com>
1999-03-10  0:00                                 ` fraser
     [not found]                               ` <7 <7c58qa$b6b$1@cf01.edf.fr>
1999-03-10  0:00                                 ` fraser
     [not found]                             ` <1999Mar9.131659. <dale-1003991644340001@r1021c-07.ppp.cs.rmit.edu.au>
1999-03-10  0:00                               ` Larry Kilgallen
1999-03-07  0:00                   ` Matthew Heaney
1999-03-08  0:00                     ` Michael Young
1999-03-08  0:00                       ` Matthew Heaney
1999-03-04  0:00             ` robert_dewar
1999-03-04  0:00           ` Ehud Lamm
1999-03-05  0:00             ` Richard D Riehle
1999-03-05  0:00               ` Nick Roberts
1999-03-06  0:00                 ` Ehud Lamm
1999-03-06  0:00                   ` robert_dewar
1999-03-06  0:00                     ` Larry Kilgallen
1999-03-06  0:00                       ` Dave Taylor
1999-03-06  0:00                         ` Bruce or Tracy
1999-03-06  0:00                     ` Ehud Lamm
1999-03-04  0:00         ` dennison
1999-03-04  0:00           ` Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox