www.digitalmars.com         C & C++   DMDScript  

D - printf_assert

reply "Matthew" <matthew stlsoft.org> writes:
We could really do with a printf_assert(), in order to print out details of
asserts and assert in a single statement
Mar 14 2004
parent reply Piotr Fusik <Piotr_member pathlink.com> writes:
We could really do with a printf_assert(), in order to print out details of
asserts and assert in a single statement
I'd prefer: assert foo == bar, "foo=$foo bar=$bar"; or (Java-like): assert foo == bar : "foo " ~ foo ~ " bar=" ~ bar;
Mar 14 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Piotr Fusik wrote:
We could really do with a printf_assert(), in order to print out details of
asserts and assert in a single statement
I'd prefer: assert foo == bar, "foo=$foo bar=$bar"; or (Java-like): assert foo == bar : "foo " ~ foo ~ " bar=" ~ bar;
I'd prefer: assert(x==1, "x: %d", x); assert(testExpression, formattingString, ...); (I like the parentheses on assert.) I think adding optional output options on assert would be great. I think I'd use it often. -- Justin http://jcc_7.tripod.com/d/
Mar 14 2004
next sibling parent "Matthew" <matthew stlsoft.org> writes:
"J C Calvarese" <jcc7 cox.net> wrote in message
news:c31vsi$vo6$1 digitaldaemon.com...
 Piotr Fusik wrote:
We could really do with a printf_assert(), in order to print out details
of
asserts and assert in a single statement
I'd prefer: assert foo == bar, "foo=$foo bar=$bar"; or (Java-like): assert foo == bar : "foo " ~ foo ~ " bar=" ~ bar;
I'd prefer: assert(x==1, "x: %d", x); assert(testExpression, formattingString, ...);
That's a good suggestion. I've spent heaps of time putting printf stuff in and around invariants this w/e, as I've been working on DTL containers. Lists were especially assertive ... ;)
 (I like the parentheses on assert.)
Indeed.
Mar 14 2004
prev sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
J C Calvarese wrote:

 I'd prefer:
 assert(x==1, "x: %d", x);

 assert(testExpression, formattingString, ...);

 (I like the parentheses on assert.)

 I think adding optional output options on assert would be great. I 
 think I'd use it often.
Me too. It's just common sense that assert with printf functionality would look like this. C/C++ programmers will instantly know how to use this. -- -Anderson: http://badmama.com.au/~anderson/
Mar 14 2004