dmd -betterC

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 21 07:00:33 PDT 2017


MysticZach wrote:

> On Wednesday, 21 June 2017 at 10:51:39 UTC, ketmar wrote:
>> there, of course, *IS* The difference. besides the aesthetical one 
>> (seeing failed condition immediately "clicks" in your head, and generic 
>> "assertion failed" message is only frustrating), there may be the case 
>> when source code changed since binary was built. here, line number gives 
>> you zero information, and you have to checkout that exact version, and 
>> go check the line. but when failed condition dumped, most of the time it 
>> allows you to see what is wrong even without switching to the old 
>> codebase (yes, "most of the time" is from RL -- it is literally *most* 
>> of the time for me, for example).
>
> How would you solve this issue?

i did in aliced: just added printing of `assert` condition. that's all. no 
variable dumps, no other things -- just `.toChar()` the condition, and 
print it. and you know what? it is *surprisingly* effective, eats *no* 
additional compiler resources, and solved all the problems with "dumb 
asserts" i had.

for some reason people insisting on printing every thing that is possible 
to print in `assert`. it is rarely interesting IRL, 'cause most of the time 
it will print nonsence anyway. failed assert usually means either that 
something went *very* wrong long before it, or it is almost immediately 
obvious *what* exactly is wrong, without dumping garbage variables.


More information about the Digitalmars-d mailing list