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: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Subject: Re: some questions re. Ada/GNAT from a C++/GCC user Date: 1996/04/01 Message-ID: <4jof0i$2u8@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 145214321 references: <4jjul6$637@ra.nrl.navy.mil> organization: Comp Sci, RMIT, Melbourne, Australia newsgroups: comp.lang.ada Date: 1996-04-01T00:00:00+00:00 List-Id: bobduff@world.std.com (Robert A Duff) writes: >You miss the point. C++ doesn't require "{" and "}" in this case -- the >case we're talking about is where no visual cues are necessary. I can >understand that one might like "begin" better than "{", but this is a >case where C++ requires nothing at all, and Ada requires "declare", >"begin", and "end", for no good reason. I am on record as being a fan of Algol 68, which is where C++ got the idea of mixing declarations and statements. However, it is quite false to say that Ada requires 'declare', 'begin' and 'end' "for no good reason". In C++, declarations and statements _can_ look very similar. See section 6.8 of Eliis & Stroustrup, which says "to disambiguate, the whole statement may have to be examined to determine if it is an expression-statement of a declaration". This creates a problem for people trying to read long listings: when they want to find the declaration of a local identifier, it can be hard to see which lines are declarations, let alone which is the right declaration. C++ programmers deal with this a simple way: they avoid long functions. Ada programmers do this too, but Ada helps with two things: (1) For variables and constants, the identifier being declared is the first thing in the line. (Ada allows, but does not require, several identifiers in one declaration. I try to avoid this.) (2) The declarations are located in specially marked regions of code. Repeat look up to outer 'procedure', 'function', 'declare', 'package' scan down to 'begin' looking for identifier until found. Of _course_ this is heavy-weight for tiny examples, but tiny examples don't benefit much from intermingled declarations either. -- Result of state election = 50% Victorians didn't get MP of their choice. Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.