comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!usc!elroy.j pl.nasa.gov!swrinde!menudo.uh.edu!cl2.cl.uh.edu!swen09d2@ucbvax.Berkeley.EDU  ( 440722148 DUGAN, TIMOTHY R)
Subject: Re: Type declarations in a subprogram
Date: 16 Jun 93 20:28:00 GMT	[thread overview]
Message-ID: <16JUN199314282536@cl2.cl.uh.edu> (raw)

In article <1993Jun16.164301@lglsun.epfl.ch>, nebbe@lglsun.epfl.ch (Robb Nebbe)
 writes...
>Why would anyone want to declare a type in a subprogram? 

First of all, the distinction between a "subprogram" and a "main program"
is somewhat artificial.  If there is a reason to do it in a main, why
wouldn't there be a reason in a sub?

Here's one of a possible infinite numbe of examples:

function Recognizer(Input : String) return Boolean is

   type State_Type is (State_1, State_2, State_3, ... );

   Current_State : State_Type := State_1;

   Return_Value : Boolean := False;

begin

   for Index in Input'range loop

      case Current_State is

         when State_1 =>
            . . .
            Current_State := . . .

         when . . .

            . . .

            Return_Value := True;

            . . .

      end case;

      exit when Current_State = State_N;

   end loop;

end Recognizer;

             reply	other threads:[~1993-06-16 20:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-06-16 20:28 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!usc!elroy.j [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-06-17 16:30 Type declarations in a subprogram cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!agate!doc.i
1993-06-17 14:48 Tucker Taft
1993-06-17 11:41 pipex!warwick!zaphod.crihan.fr!vishnu.jussieu.fr!univ-lyon1.fr!scsing.swi
1993-06-16 19:38 cis.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.usafa.af.mil!kirk!cwarack
1993-06-16 16:35 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!usenet.ins.
1993-06-16 15:17 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
replies disabled

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