Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-02-16 13:30:56


Ion Gaztañaga <igaztanaga_at_[hidden]> writes:

> Hi David,
>
>> But it's not possible to tell is that someone has passed you something
>> nasty when somebody else uses no_throw and you're just getting a
>> reference to the object. That's my whole point. Strong invariants
>> make it possible to develop code separately without adding lots of
>> nasty preconditions everywhere to "ensure" that nobody has given you
>> something nasty.
>
> Well, if the programmer never checks the error of the construction
> function when he is explicitly requesting a no-throw, the programmer is
> the problem. So if the programmer requests a new[](std::nothrow) and
> does not check if the returned pointer is not null, and you receive a
> null pointer, you have the same problem.

Which is why we assume pointers may be NULL. Not so with references.
Everything you've just said misses the point by such a wide margin
that I don't know where to begin, and I don't have time to finish
right now, so I'll just say this:

  When a precondition is violated, the programmer that violates it "is
  the problem." I advocate a system that requires fewer
  preconditions, and thus offers fewer opportunities for anyone to "be
  the problem."

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk