June 04, 2004
"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message news:c93r3r$1a8c$1@digitaldaemon.com...
> Walter wrote:
>
> >"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message news:c93ll4$120a$1@digitaldaemon.com...
> >
> >
> >>Walter wrote:
> >>
> >>
> >>>My normal practice is to put some debugging printf's before the assert,
> >>>
> >>>
> >and
> >
> >
> >>>rerun the program.
> >>>
> >>>
> >>But your working on a compiler.  The conditions are easily re-produced in that type of program.
> >>
> >>
> >
> >Compilers aren't the only programs I've written. For GUI programs, I'd have the printf's write to a log file. As for reproducing the error, that can be tricky in, for example, multithreaded programs, but you cannot fix it and verify the fix anyway until you can find a way to reproduce it.
> >
> >Just printing out the value of the assert variable rarely is sufficient anyway, as it is usually the tail end of a problem that started sometimes much earlier.
> >
> >
> Right but being able to print values out in an assert would help. Normally when I've found a unique variable for the error I can work the code backwards and it is more easily reproducible.

I'd like to put it another way. What's the reason not to supply a slightly more informative assert? Even if we can just have a message string, a la the C/C++ message_assert idiom, that would be very helpful.



June 04, 2004
D gets the language and compiler and user code to work together with foreach/opApply. Why can we not have something similar for assert()?

"Mike Swieton" <mike@swieton.net> wrote in message news:pan.2004.05.26.23.06.25.423500@swieton.net...
> On Wed, 26 May 2004 21:10:08 +0000, Sean Kelly wrote:
>
> > And new assert functions can always be written if special information is desired.
> >
> > Sean
>
> This is not strictly true. If a user replaces the built-in assert with a custom one, a custom one cannot report the line number of a failed assertion, while the builtin one can.
>
> Mike Swieton
> __
> The difference between losers and winners is that losers don't fail enough.
> - Ross Jeffries
>


June 04, 2004
"Walter" <newshound@digitalmars.com> wrote in message news:c959fd$17un$2@digitaldaemon.com...
>
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:c93v0g$1g48$1@digitaldaemon.com...
> > I would agree that adding a string that describes the error is probably unnecessary.  But if you throw an exception, as I believe assert currently does, you lose valuable context info (stack backtrace and variables) that would be useful in debugging the problem.
>
> But a decent debugger gives you that already. Why put it in the language?

Flexibility. I've not yet used a debugger on D, and have reasonably high-level in the quality of the libraries through a combination of DbC and manually inserting and then removing error strings. Message assertions would have simply meant that I would have spent less time writing those same libs, time which I could have spent on other libs or pontificating on this NG.


1 2 3 4
Next ›   Last »