Re: while (1) vs. for ( ;; )
- From: mwojcik@xxxxxxxxxxx (Michael Wojcik)
- Date: 30 Aug 2005 18:33:38 GMT
In article <4314194B.CD000917@xxxxxxxxxx>, Wolfgang Riedel <wolfgang.riedel@xxxxxxxxxx> writes:
> Richard Heathfield wrote:
> > In the cases where you are sure the parameters are okay, you can call the
> > function directly, avoiding the overhead of the parameter check. (You could
> > reasonably add assertion checks here, since they cannot possibly fire if
> > your program is correct.)
> >
> > When you're not sure, you call the validation function - which either calls
> > the "do it" function directly or, perhaps slightly more cleanly, returns an
> > "everything's fine" value, after which you can proceed to call the "do it"
> > function yourself.
> >
> IIRC that's one reason, why COBOL has multiple entry points into functions.
<OT>
COBOL doesn't have multiple entry points into functions. Functions
in COBOL are a fairly restrictive language feature. I suspect you're
thinking of "programs", which is what COBOL calls the things that are
closest to what C calls "functions", or what are sometimes called
"subroutines".
Standard COBOL does not permit multiple entry points in programs, but
it's an extension in several popular implementations.
</OT>
Multiple entry points would certainly be *a* way of implementing the
design Richard describes, but I don't see much justification for
using them that way. Just using two functions would be clearer and
less error-prone, I suspect. And it strikes me as unlikely that,
conversely, this design would be used to argue for allowing multiple
entry points in a language.
I must admit, though, that I'm not fond of Richard's scheme in most
cases; unless a function is time-critical or the checks are very
expensive I don't see the advantage to skipping the checks. That
shifts the burden of validation from the program to the programmer.
--
Michael Wojcik michael.wojcik@xxxxxxxxxxxxxx
Art is our chief means of breaking bread with the dead ... but the social
and political history of Europe would be exactly the same if Dante and
Shakespeare and Mozart had never lived. -- W. H. Auden
.
- References:
- while (1) vs. for ( ;; )
- From: Michael B Allen
- Re: while (1) vs. for ( ;; )
- From: Richard Heathfield
- Re: while (1) vs. for ( ;; )
- From: Alan Balmer
- Re: while (1) vs. for ( ;; )
- From: Richard Heathfield
- Re: while (1) vs. for ( ;; )
- From: Alan Balmer
- Re: while (1) vs. for ( ;; )
- From: Mark B
- Re: while (1) vs. for ( ;; )
- From: Alan Balmer
- Re: while (1) vs. for ( ;; )
- From: Richard Heathfield
- Re: while (1) vs. for ( ;; )
- From: Wolfgang Riedel
- while (1) vs. for ( ;; )
- Prev by Date: Re: confused abt file operations
- Next by Date: Re: low-level question
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|