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.1 required=5.0 tests=BAYES_05,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b0d68c502c0ae6 X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: Printing Enum Variable Re: Linux World Date: 1999/03/03 Message-ID: <36DDD621.6FDE496B@hso.link.com>#1/1 X-Deja-AN: 450964482 Content-Transfer-Encoding: 7bit References: <7bfc2n$jl9@dfw-ixnews5.ix.netcom.com> <7bhh26$r7c$1@remarQ.com> <36DCAC1F.430E2C5E@aasaa.ofe.org> <7bk4v8$kl8$1@remarQ.com> <36DDA761.7B4E8099@aasaa.ofe.org> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Raytheon Training Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-03-03T00:00:00+00:00 List-Id: 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!"