Re: while (1) vs. for ( ;; )
- From: Wolfgang Riedel <wolfgang.riedel@xxxxxxxxxx>
- Date: Tue, 30 Aug 2005 10:31:07 +0200
Richard Heathfield wrote:
>
> Alan Balmer said:
>
<>
> [avoiding multiple returns]
>
<>
> That's a reasonable argument. Here's another, which is diametrically
> opposed. :-)
>
> There are two tasks here - the validation of parameters, and the task for
> which the function was actually written. Now, there may well be times when
> you know perfectly well that the parameters are valid, because it's
> actually impossible for them not to be valid. And there are times when
> you're not sure.
>
> 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.
.
- Follow-Ups:
- Re: while (1) vs. for ( ;; )
- From: Michael Wojcik
- Re: while (1) vs. for ( ;; )
- 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
- while (1) vs. for ( ;; )
- Prev by Date: How to free dynamically allocated array?
- Next by Date: Re: How to free dynamically allocated array?
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|