From: cis.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news .usafa.af.mil!kirk!cwarack@ucbvax.berkeley.edu (Chris Warack <cis.ohio-state.e
Subject: Re: Type declarations in a subprogram
Date: 16 Jun 93 19:38:46 GMT [thread overview]
Message-ID: <1vnss6$dmv@usafa2.usafa.af.mil> (raw)
In article <C8q3Ep.JM2@irvine.com>, adam@irvine.com (Adam Beneschan) writes:
|> 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? I have
|> > occaisionally done it in toy programs (a single procedure) but have
|> > never needed it in any "real" code that I have written. I was wondering
|> > if it supports some particular programming paradigm or if it was just
|> > included in the language for toy programs and because no one had a good
|> > reason to exclude it.
|> >
|> > If anyone has an example where a local type declaration makes the code
|> > clearer or more elegant I would be particularly interested in seeing it.
|>
|> I do this fairly frequently in real code. One example that I found in
|> my code is:
|>
[...] explanation and example deleted.
While Adam gives an example of why you might want this capability, I have
to ask why you wouldn't want it? To prohibit it would just add additional
rules that apply to some declarative parts but not to others. Why is this
a benefit? It's simpler to define declarative parts the same. Given that,
you could declare a type in the middle of a loop if you wanted to by using
a block statement. I'll probably never do it, but it's nice to know that
the declarative part of a package spec, subprogram, and block statement
are the same.
--
Christopher A. Warack, Capt, USAF
Computer Science Department, US Air Force Academy
cwarack@kirk.usafa.af.mil (719) 472-2401
next reply other threads:[~1993-06-16 19:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [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 20:28 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!usc!elroy.j
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