assert(condition[, message]) patch

Joseph Lisee jlisee at umd.edu
Tue Aug 1 11:18:23 PDT 2006


In article <ealh03$htp$1 at digitaldaemon.com>, Sean Kelly <sean at f4.ca> 
wrote:

> Joseph Lisee wrote:
> > In article <e5l5v8$1g7j$1 at digitaldaemon.com>,
> >  Tom S <h3r3tic at remove.mat.uni.torun.pl> wrote:
> > 
> >> Lars Ivar Igesund wrote:
> >>> Because not all the users will have access to the source, or be inclined 
> >>> to
> >>> see it. Unless the user get's a readable/understandable assert message
> >>> he/she might not get enough information to actually reproduce a test case
> >>> for the developer to peruse.
> >>>
> >>> Walter, this is a no-brainer, please put it in.
> >> ++votes;
> >>
> >> /+
> >> when you release your app to some testing team, you might want to leave 
> >> asserts in. While an error message containing the line number and 
> >> filename could be helpful, an additional message could be priceless. 
> >> E.g. assert(fileNameContainsNoSpaces(foo)); won't tell you that the 
> >> 'foo' really was something like '^&^34 5+23 3(43D678[SAFer6_[]' which 
> >> might mean some mem corruption or forgetting a .dup somewhere in your 
> >> code. You'd instead go searching for some logic problems that wouldn't 
> >> solve the problem.
> >> +/
> > 
> > I vote for the assert(condition, "msg"), construct as well.
> 
> This feature was added a number of builds ago.
> 
> 
> Sean

That is what happens when I don't read the documentation close enough 
and not pay attention to message dates.

It should also be noted that the in the Contract Programming page of the 
documentation it only mentions "assert(expression)".  While It does link 
to the full documentation on the assert expression should that page also 
mention the option for a message?

Sorry to clutter the mailing list.  I will just go back to my attempt at 
wrapping C++ with doxygen + python. Yes I am aware of the D module for 
Swig, but I am going for something more elegant and this effort is a 
good C++, Python, and D programming exercise.

-Joseph



More information about the Digitalmars-d mailing list