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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,7c7fba57c4978feb X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Why no named case statements? Date: Fri, 04 Sep 2009 20:29:28 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <5233a224-07c1-4a7b-906e-b4cb8e193c85@y42g2000yqb.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1252110568 3924 192.74.137.71 (5 Sep 2009 00:29:28 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 5 Sep 2009 00:29:28 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:ZDqrI8Trr8MpvxxD78avT8gQOrY= Xref: g2news2.google.com comp.lang.ada:8172 Date: 2009-09-04T20:29:28-04:00 List-Id: Britt Snodgrass writes: > Ada allows optional names for loops and declare blocks but not for > case or if statetements. Why not, since these are also multi-line > statements that terminate with an 'end" keyword? I sometimes use loop > names to clearly indicate the purpose of the loop... I think loop names are for doing exits from nested loops. If you're using them to "clearly indicate...", then I think you are unintentionally obfuscating. Reader thinks, "Uh, oh, there's nested exits in here..." But it's a false alarm. If you want to clearly indicate the purpose of a block of code, I think a comment is what you want, plus surrounding that block with blank lines. As in: ... -- previous code -- Decide this: case Some_Variable is ... end case; ... -- following code >... and have wished I > could do the same for case statements, e.g., > > Decide_This: > case Some_Variable is > ... > end case Decide_This; I suppose you could do this: Decide_This: begin case Some_Variable is ... end case Decide_This; end Decide_This; Actually, in GNAT there are some places that look something like this: case Some_Variable is when This => Do_This: begin .. end Do_This; when That => Do_That: begin .. end Do_That; ... -- and so on for hundreds of cases end case; > or similarly for long if statements: > > Decide_That: > if Whatever then > ... > end if Decide_That: > > Such names could also be used in the outline view of an IDE like > Eclipse to support quick location of the named entity. > > I suppose there was some rationale so I'm curious what it was. Loop names were invented so you could exit from nested ones. Block names were invented so you could refer to nested objects using dot notation, as in Block_Name.Local. I suppose nobody thought of naming particular statements as you would a procedure name. That's my guess, as to rationale. - Bob