comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Why no named case statements?
Date: Fri, 4 Sep 2009 16:47:03 -0700 (PDT)
Date: 2009-09-04T16:47:03-07:00	[thread overview]
Message-ID: <7c9ffecd-a797-44c0-90be-b8d8202aabba@f20g2000prn.googlegroups.com> (raw)
In-Reply-To: 5233a224-07c1-4a7b-906e-b4cb8e193c85@y42g2000yqb.googlegroups.com

On Sep 4, 4:06 pm, Britt Snodgrass <britt.snodgr...@gmail.com> wrote:
> 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?

Probably because for loops and blocks, the names are useful for
something else.  For loops, you can specify the loop name in an EXIT
statement (useful if you nest loops and want to exit the outer one).
For blocks, the block name can be used as part of an expanded name
(i.e. if you declare a variable V in the declaration portion of the
declare block, you can refer to Block_Name.V).  My guess is that since
the names were needed for those purposes for loops and blocks, but not
for anything else, the original language designers didn't bother to
allow them for other compound statements.


 I sometimes use loop
> names to clearly indicate the purpose of the loop and have wished I
> could do the same for case statements, e.g.,
>
> Decide_This:
> case Some_Variable is
> ...
> end case Decide_This;
>
> or similarly for long if statements:
>
> Decide_That:
> if Whatever then
> ...
> end if Decide_That:

I'd just use comments.

-- Decide_This:
   case Some_Variable is
       ...
   end case; -- Decide_This

                               -- Adam



  reply	other threads:[~2009-09-04 23:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04 23:06 Why no named case statements? Britt Snodgrass
2009-09-04 23:47 ` Adam Beneschan [this message]
2009-09-05  0:29 ` Robert A Duff
2009-09-05  0:49   ` Adam Beneschan
2009-09-05  1:04     ` Robert A Duff
2009-09-05  8:18 ` Dmitry A. Kazakov
2009-09-06 12:44   ` Robert A Duff
2009-09-06 17:46     ` Britt
2009-09-07  7:27       ` Ole-Hjalmar Kristensen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox