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.3 required=5.0 tests=BAYES_00,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: fraser@synopsys.com (Fraser Wilson) Subject: Re: Printing Enum Variable Re: Linux World Date: 1999/03/03 Message-ID: <7bk5c2$8ge$1@remarQ.com>#1/1 X-Deja-AN: 450875263 References: <7bfc2n$jl9@dfw-ixnews5.ix.netcom.com> <7bhh26$r7c$1@remarQ.com> <36DCAC1F.430E2C5E@aasaa.ofe.org> X-Complaints-To: newsabuse@remarQ.com X-Trace: 920492226 KZBGBQC4S164892E1C usenet77.supernews.com Organization: Vegetarian Ada Programmers Newsgroups: comp.lang.ada Date: 1999-03-03T00:00:00+00:00 List-Id: I nearly cried when dstarner98@aasaa.ofe.org said: >Note this has certain advantages over Ada's default method - it lets you >print a good string, instead of the mangled string that went into the >code (which, in my experiance, Ada further mangles by making it all >upper case), and it lets you internationalize the code easily. Well, I have to disagree on this. Printing a string representation of a literal is not something that goes out to the User (bless his heart). It's for my information, and the all caps, direct representation of the name is exactly what I need. I understand gdb can do something similar, but debuggers are a poor substitute for understanding the code. If you add an extra element to the enumeration, will the compiler warn you about the switch statement? What if the strings were stored in an array? >IMO, printing enumerator literals, as is, is a quick and dirty hack that >should be used only if you're the only user. Again, it's for my eyes only. And I wouldn't call it a quick'n'dirty hack. It's a useful technique. > (How should you print a value that doesn't have an >associated name, for instance?) I'd completely forgotten you could do that in C. So an enum is basically a shorthand to avoid writing lots of #defines? Doesn't that somewhat miss the point. Oh, dear, the topic tree is straining ... Fraser.