Re: Smart Pointers: Is there something similar to smart pointers in C?



Rod Pemberton said:

"Bill Pursell" <bill.pursell@xxxxxxxxx> wrote in message
news:1158043184.686635.149140@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If you are programming at a level where
you want a garbage collector, then you shouldn't be
programming in C. (My opinion.) The thing that takes
the place of a "smart pointer" in C is a "smart programmer".
You keep track of these things yourself.

Everyone here says that. I like that ideology and want to agree with
that.

Feel free.

But, apparently, it is a falsehood. If programmers were responsible, no
one here would be complaining about fgets and sprintf buffer overflows,

Wrong. The responsible programmers are the ones who know about these issues
(not that fgets is particularly vulnerable to buffer overflows as long as
you tell it the truth), and they can frequently be heard warning other
people about those issues, but they don't /complain/ about them. They write
their code defensively.

needing restrict pointers,

I've never seen a good justification for such a need.

free not setting the pointer to NULL,

It would be nice, but it's no big deal.

ptrdiff_t's insufficient range,

Since I hardly ever use it, why should I care?

undefined behavior for out-of-bounds pointers,

The solution to that is easy. Keep your pointers under control.

or any
other limitation, bug, or idiosyncratic feature of the C language.

Oh, come on - asking C programmers not to complain about C would be like
asking Formula 1 drivers not to complain about Formula 1 cars.


There'd
be no need for snprintf, strlcat, or garbage collection.

I have not yet seen a convincing argument that any of these is needed.
Certainly I've never needed them.

<snip>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: Smart Pointers: Is there something similar to smart pointers in C?
    ... Rod Pemberton wrote: ... you want a garbage collector, ... If programmers were responsible, no ... I have another opinion. ...
    (comp.lang.c)
  • Re: Garbage Collection Survey
    ... > We are interested in programmers' experiences of programming languages ... The garbage collector can only carry a certain amount without ... of bugs. ... tradeoff, and this tradeoff can be minimised with some awareness of ...
    (comp.lang.lisp)
  • Re: Smart Pointers: Is there something similar to smart pointers in C?
    ... you want a garbage collector, ... If programmers were responsible, no ... needing restrict pointers, free not setting the pointer to NULL, ptrdiff_t's ... harrassed by the persistent complaints of dozens of self-proclaimed experts ...
    (comp.lang.c)
  • Re: Smart Pointers: Is there something similar to smart pointers in C?
    ... you want a garbage collector, ... The responsible programmers are the ones who know about these issues (not that fgets is particularly vulnerable to buffer overflows as long as you tell it the truth), and they can frequently be heard warning other people about those issues, but they don't /complain/ about them. ... yes, YOU are perfect Heathfield, I am not. ...
    (comp.lang.c)
  • Re: Realplayer, the BBC and a very off-topic request!
    ... Chris Hughes wrote in message ... >> So Chris, do you wish to continue to complain, or do something useful? ... It may be worth remembering that the vast majority of programmers these ... days are likely to be working on RISC OS projects "for love" rather than ...
    (comp.sys.acorn.misc)