Re: Why leave the error handling to the caller?
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Mon, 18 Jun 2007 04:00:37 +0000
Malcolm McLean said:
"Richard Heathfield" <rjh@xxxxxxxxxxxxxxx> wrote in message
news:7oCdnWXORp3b-ujbnZ2dnUVZ8szinZ2d@xxxxxxxxx
Malcolm McLean said:The problem is that the code is disproprtionate.
<snip>
There quite a strong case for a safemalloc() library function that
does terminate with an error message on fail.
No, there isn't. Library routines have no business deciding to
terminate the program.
If you try hard enough, the code /can/ be disproportionate.
Let's say I want to set up a structure with a list of strings.
I looked at your code, and found it lacking in any significant evidence
that you are a regular clc subscriber.
<snip>
Now that is about as simple as an arbitrary dataset is likely to be -
just an array of strings. I counted 14 lines purely to handle malloc()
failures.
Get back to me when you've written it properly.
The code is untested and there is probably something wrong with it.
You'd be amazed. Still, look on the bright side - it didn't actually
call gets().
To my mind this is a very serious disadvantage of the "caller handles
error" paradigm.
To my mind it was just a bunch of broken code.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.
- Follow-Ups:
- Re: Why leave the error handling to the caller?
- From: Malcolm McLean
- Re: Why leave the error handling to the caller?
- References:
- Why leave the error handling to the caller?
- From: Chad
- Re: Why leave the error handling to the caller?
- From: Malcolm McLean
- Re: Why leave the error handling to the caller?
- From: Richard Heathfield
- Re: Why leave the error handling to the caller?
- From: Malcolm McLean
- Why leave the error handling to the caller?
- Prev by Date: Re: Why leave the error handling to the caller?
- Next by Date: Re: when to use ; and when to use ,
- Previous by thread: [OT] Re: Why leave the error handling to the caller?
- Next by thread: Re: Why leave the error handling to the caller?
- Index(es):
Relevant Pages
|
|