comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Riehle <richard@adaworks.com>
Subject: Re: labeling (was: partitioning (was: Future))
Date: Fri, 15 Mar 2002 08:07:12 -0800
Date: 2002-03-15T15:59:19+00:00	[thread overview]
Message-ID: <3C921C30.F5FF9CBF@adaworks.com> (raw)
In-Reply-To: mailman.1016027822.21009.comp.lang.ada@ada.eu.org

In my original comment about the value of labels for
many Ada constructs, I did not anticipate the many
variations on the theme that might be concocted.

My comments were a complaint that curly braces in
the C family of languages would be more useful if they
permitted scope delimiting labels that could be checked
by the compiler.    We wouldn't need these everywhere,
only where they would add clarity.

Ada already provides this feature for adding clarity.
And we can insert it anywhere we wish in long blocks
of code (not that I am recommending long blocks of code).
It is nice that the labels are checked by the compiler as
well as improving readability by humans, programmers
included.

I really don't think it is necessary to add new labeling
features to the language for selection statements, as
some have suggested.   For me, end case and end if
are quite enough.

However, it is sometimes useful to create a begin..end
block with a label for especially long constructs.   For
example,

        case X is
             when Sigma => Sigma_Process:
                                       begin
                                            sequence-of-statements
                                       end Sigma_Process;
            when Theta =>  Theta_Process:
                                      begin
                                           handled-sequence-of-statements
                                      exception
                                           sequence-of-statements
                                      end Theta_Process;
        end case;

If it is a really long case statement, the case statement can
be wrapped in a labeled begin..end block.

However, I don't favor this for compilers that support pragma
inline well.   Instead, the above code can be made more effective
by promoting it to a private child package, or enclosing the long
begin..end statements into nested inlined procedures.  Even the
case statement itself can be promoted to an inlined procedure.

        procedure P is
             -- local declarations
             procedure Theta_Process is ... begin ... end Theta_Process;
             pragma Inline(Theta_Process);
             procedure Sigma_Process is ... begin ... end Sigma_Process;
             pragma Inline(Sigma_Process);
             -- more declarations
       begin
            case X is
                when Sigma => Sigma_Process;
                when Theta =>  Theta_Process;
            end case;
      end P;







  parent reply	other threads:[~2002-03-15 16:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-13 13:55 labeling (was: partitioning (was: Future)) Christoph Grein
2002-03-13 17:50 ` Wes Groleau
2002-03-15 16:07 ` Richard Riehle [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-03-18  5:59 Christoph Grein
2002-03-18 22:52 ` Wes Groleau
2002-03-15  8:20 Christoph Grein
2001-11-09 17:59 Future with Ada Michal Nowak
2002-02-26  4:12 ` Jim Rogers
2002-02-27 17:51   ` Warren W. Gay VE3WWG
2002-02-28 17:45     ` Michal Nowak
2002-02-28 18:53       ` Hyman Rosen
2002-03-01 17:26         ` Jeffrey Carter
2002-03-03  8:26           ` Hyman Rosen
2002-03-03 17:47             ` Chad R. Meiners
2002-03-04 16:30               ` Hyman Rosen
2002-03-05  1:41                 ` Richard Riehle
2002-03-05 21:35                   ` Wes Groleau
2002-03-05 22:04                     ` Marin David Condic
2002-03-06 16:36                       ` Georg Bauhaus
2002-03-06 17:27                         ` Marin David Condic
2002-03-07 16:04                           ` Georg Bauhaus
2002-03-07 16:42                             ` Marin David Condic
2002-03-11 20:02                               ` Wes Groleau
2002-03-11 23:56                                 ` Marin David Condic
2002-03-12 16:47                                   ` code partitioning (was: Future with Ada) Wes Groleau
2002-03-12 17:56                                     ` Marin David Condic
2002-03-13 13:42                                       ` labeling (was: partitioning (was: Future)) Wes Groleau
2002-03-14 12:46                                         ` Michal Nowak
2002-03-14 17:27                                           ` Wes Groleau
2002-03-14 20:27                                             ` Marin David Condic
2002-03-15  8:00                                         ` Tarjei T. Jensen
2002-03-15 15:10                                           ` Wes Groleau
replies disabled

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