comp.lang.ada
 help / color / mirror / Atom feed
From: Britt <britt.snodgrass@gmail.com>
Subject: Re: Why no named case statements?
Date: Sun, 6 Sep 2009 10:46:26 -0700 (PDT)
Date: 2009-09-06T10:46:26-07:00	[thread overview]
Message-ID: <26253452-b337-413c-9f7f-9e0a9b4f66fa@t2g2000yqn.googlegroups.com> (raw)
In-Reply-To: wccfxb0cke9.fsf@shell01.TheWorld.com

On Sep 6, 7:44 am, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
> "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de> writes:
>
> > Ada has labels:
>
> > <<Decide_This>>
> >    case Some_Variable is
> >        ...
> >    end case;
>
> > <<Decide_That>>
> >    if Whatever then
> >       ...
> >    end if:
>
> I prefer comments:
>
>    -- Decide this.
>    case Some_Variable is
>        ...
>    end case;
>
>    -- Decide that.
>    if Whatever then
>       ...
>    end if:
>
> To me, a label is a warning that gotos are lurking around the place.

Labels are also useful as breakpoint targets if the compiler produces
associated symbolic information that can then be used by the
debugger.  Using labels for this purpose is much better (more
maintainable) than breaking on line numbers.  Such permanent
breakpoints are sometimes useful in formal white-box test procedures.
SPARK was recently changed to allow  use of Ada labels for this
purpose (breakpoints, not gotos), and the GNATPP pretty-printer now
has a new switch to format Ada labels on separate lines (as shown in
Dmitry's example).

The responses to my original question have been informative.  I think
I would still like for the next revision of Ada to allow a name on any
multi-line construct that closes with an end keyword.  This would make
the language more symmetric, I think.  It would also be useful if Ada
IDEs included both names and labels in their outline view to
facilitate source code navigation.

- Britt



  reply	other threads:[~2009-09-06 17:46 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
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 [this message]
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