Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-08-31 12:55:49


Kevlin Henney wrote:

> Valentin Bonnard wrote:
> [...]
> > For boost library authors, the first need is perhaps not as great as
> > that for a user dotting their own code w/ assertions. Naming and
> > describing what constraint was violated is often more useful to a
> > library user than receiving a mysterious message about a piece of code
> > they have nothing to do w/!
>
> This can easilly be done with a comment:
>
> // must fobnicate before we tweak
> assert (x ? t(3) : 3434==i+j);
>
> And there was me thinking that the compiler ignored comments ;-)
>
> If you wish to do this 'properly' w/ assert:
>
> assert (("must fobnicate before we tweak", x ? t(3) : 3434==i+j));

Then the string will take space in the program (I have read
that it was a problem for big apps).

I would rather add an argument to assertion:

  assertion ("must fobnicate before we tweak", x ? t(3) : 3434==i+j);

so it would print:

foo.h:23:assertion failed: x ? t(3) : 3434==i+j
foo.h:23:'cause: must fobnicate before we tweak

> I think both of these help to reinforce points about usability and
> friendliness! Another point here being that library user and author are
> different roles, and there can be quite different requirements for what
> may superficially seem to be the same concept, ie debugging.

Both want to know what failed, in which file, called from where,
why the assertion was necessary (in case it isn't obvious).

I don't see the difference.

And they would like the computer to tell them why it failed. ;-)

-- 
Valentin Bonnard

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