Boost logo

Boost :

From: Kevlin Henney (Kevlin.Henney_at_[hidden])
Date: 1999-09-01 03:40:02


Valentin Bonnard wrote:
> Kevlin Henney wrote:
[...]
> 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).

     This is mostly irrelevant folklore. But if space genuinely were a
     concern, it is unlikely that I would be compiling everything in debug
     mode (which reinforces a point I made earlier about not imposing
     universal NDEBUG on developers). Similarly your use of a string
     literal in the example below will have exactly the same consequences.

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

     Yes, precisely: this was exactly my point about usability! The
     assertion you have defined is more useful and expressive than the
     standard assert for just this reason, which was one of the problems I
     was highlighting.

> 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.

     Spoken like a "true library developer" :-(

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

     Yeah, I'm working on a class for that right now... ;->

     Kevlin


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