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 X-Google-Thread: 109fba,f92fbb4a0420dd57 X-Google-Attributes: gid109fba,public From: mab@dst17.wdl.loral.com (Mark A Biggar) Subject: Re: some questions re. Ada/GNAT from a C++/GCC user Date: 1996/04/01 Message-ID: <4jovi9$c2b@wdl1.wdl.loral.com>#1/1 X-Deja-AN: 145247687 references: organization: Loral Western Development Labs newsgroups: comp.lang.ada,comp.lang.c++ Date: 1996-04-01T00:00:00+00:00 List-Id: In article rogoff@sccm.stanford.edu writes: > > Why doesn't Ada 95 allow declarations to be interspersed with ordinary > > statements as C++ does? (Or does it? _Ada as a Second Language_ is a > > big book!) It seems to me that the C++ approach is a small but > > definite win. Does it interact very badly somehow with all those > > guarantees on elaboration order? > > To intersperse declarations, you have to use a block_statement, like > this: > > for I in Some_String'Range loop -- I wish I could easily use an iterator here ;-) > declare > X: constant Character := Some_String(I); > begin > ... > end; > end loop; > > To me, the "declare", "begin", and "end" are just useless verbosity. > I prefer the C++ rule. > >Yes, this seems needlessly verbose. Any Ada guru have a good reason why it has >to be this way? Yeah, 2 reasons. The first goes clear back to the original Ada Strawman documnt which calls for a clear distinction between declarations and code statements. The second reason is that is also the method of wraping an exception handler around soem arbitary piece of code: for I in Some_String'Range loop declare X: constant Character := Some_String(I); begin ... exception when ... ; end; end loop; -- Mark Biggar mab@wdl.loral.com