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: bobduff@world.std.com (Robert A Duff) Subject: Re: some questions re. Ada/GNAT from a C++/GCC user Date: 1996/04/01 Message-ID: #1/1 X-Deja-AN: 145245482 references: <315D902C.6F7B@escmail.orl.mmc.com> <4jmuj5$lkh@dayuc.dayton.saic.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-04-01T00:00:00+00:00 List-Id: In article <4jmuj5$lkh@dayuc.dayton.saic.com>, John G. Volan wrote: >Okay, then, can anybody who was in on the Ada83/Ada95 design process >give us a more comprehensive rationale for this strict separation, one >consequence of which being the need for declare statements? I was in on the Ada 95 design process, and the reason is simple: It was like that in Ada 83, and there was no mandate to change it. I was not in on the Ada 83 design, but I suspect it has something to do with the Pascal heritage. Also, some people have said they find it easier to read the code if they can find the declarations. I don't really agree with that, but I suppose it's mainly a matter of taste. > -- This is NOT Ada, this is CRAPOLA (C-Reminiscent Ada-like Perversion > -- Of Language Aspects) :-) : Now, now. I see the smiley, but still, this is just an ad-hominem attack. > begin > ... > if Smaller then > X : Integer; > ... > elsif Bigger then > X : Long_Integer; > ... > end if; > ... > -- is X in scope here, and if so, what the heck is it? No, X is not in scope here. There are two things called X, and their scopes do not overlap. The first X starts to exist at the beginning of the 'then' part, and ceases to exist at the end of that statement list. The semantics of CRAPOLA should be exactly the same as if, in Ada, you put declare-begin-end: if Smaller then declare X : Integer; begin ... end; elsif Bigger then declare X : Long_Integer; begin ... end; end if; > ... loop > Y : Integer; > Get (Y); > type A is array (1 .. Y) of Integer; > package P is new Generic_P (A); > -- do these things get elaborated & destroyed every iteration? Yes. And if any of the declarations need finalization, they will get finalized at the end of each iteration. > ... > end loop ... ; > ... > -- are Y, A, and P still in scope here? No. > end ... ; >I assume that the only thing that would make sense would be to treat >every structured statement as the moral equivalent of a begin/end. You assume right. That is, we're arguing about syntactic sugar; the semantics doesn't change if you allow declare-begin-end to be left out. - Bob