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,f92fbb4a0420dd57 X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: some questions re. Ada/GNAT from a C++/GCC user Date: 1996/04/02 Message-ID: <3160E91E.1627@lfwc.lockheed.com>#1/1 X-Deja-AN: 145433522 references: <315FCD11.D7E@lfwc.lockheed.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (Macintosh; I; 68K) Date: 1996-04-02T00:00:00+00:00 List-Id: Robert A Duff wrote: > > But what about the case where I don't *want* to > name it? Adding lots of names doesn't make the code more readable. You > only want to add names when there's something conceptually name-able. OK - I'll walk out onto the limb you've so kindly offered. I suspect that, if you find yourself creating a new scope in "real" code that has no purpose sufficiently cohensive as to be named, that you need to review your program structure. (And out come the saws... :) > True. But don't forget that the compiler is just checking that the > names match up, which is useful, but it's not checking that the names > actually tell the truth about what "a_scope" is all about. True, just like it can't tell if any user-defined identifier has the meaning it should. I think the consistency checking alone is very useful. Consider: if ... then -- scope_1 ... if .. then -- scope_a ... end if; -- scope_1 ... end if; -- scope_a Get a page/screen break in just the wrong place, and you can easily mislead the reader as to the structure of your program. It would be nice if Ada allowed the naming of if/case statements, just like loops/blocks. > Note that the block_statement *name* is option in Ada, which I think is > good -- you can name it if there's a name the gives useful information, > but if the name is just "The_Loop_Body" or "The_Else_Part", you can omit > it. The fact that local scope naming is optional isn't relevant, in my mind. For that matter, putting a name on the end of most scopes is optional. If I'm writing a quickie example, I might not put a name on the end of my subprograms. But for maintainable code, I always put a name on the end (and a comment on the begin, for that matter.) I try to name all my scopes, in part to assure myself (and the reader) as to the legitimate purpose of that scope, and in part to (hopefully) improve readability of any important code. And, since I like to return strings and other variant-sized objects from functions, I tend to have my share of block statements. By the way, do you have a problem with the "begin" keyword in a subprogram? I suppose it would also be considered unnecessary, if I understand your position correctly. What about the "exception" keyword, either in block statements or subprograms?