<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Talin wrote:
<blockquote
cite="mid:CABwJDdmR-YZEkMiX0DK7caJhjr7kR_ihHgkX5hn7gaMQhJRyKw@mail.gmail.com"
type="cite">On Thu, Jul 28, 2011 at 1:29 PM, Chris Lattner
<span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:clattner@apple.com">clattner@apple.com</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt
0.8ex; padding-left: 1ex;">
<div style="">
<div class="im">
<div>
<div>On Jul 28, 2011, at 12:07 PM, Talin wrote:</div>
<blockquote type="cite"><span
style="border-collapse: separate; font-family: Helvetica; font-style:
normal; font-variant: normal; font-weight: normal; letter-spacing: normal;
line-height: normal; text-indent: 0px; text-transform: none; white-space:
normal; word-spacing: 0px; font-size: medium;">
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px
0.8ex; padding-left: 1ex;">
<div style="">
<div>
<div>
<blockquote type="cite"><span
style="border-collapse: separate; font-family: Helvetica; font-style:
normal; font-variant: normal; font-weight: normal; letter-spacing: normal;
line-height: normal; text-indent: 0px; text-transform: none; white-space:
normal; word-spacing: 0px; font-size: medium;">
<div>
<div>
<div>Because the stream is a raw_ostream, LLVM types and
values can easily be printed to the stream without having to convert
them to string form.</div>
</div>
</div>
</span></blockquote>
<br>
</div>
</div>
<div>I'm unconvinced that this is worth it at all. This is
only going to allow you to "avoid going into the debugger" in the most
trivial cases.</div>
<div><br>
</div>
</div>
</blockquote>
<div>Question - are you opposed to having a general "assertion
with streamed arguments" facility in llvm/Support at all, or are you
merely opposed to the work involved in replacing the existing
assertions en-masse? If it's the latter, I'll make you a deal - every
time I get an assert that I don't think gives me enough information,
I'll send a patch to improve it. But that can only happen if the
general mechanism is in place first. And I'd use that general mechanism
in my own code regardless of whether it's used in LLVM or not.</div>
</span></blockquote>
<br>
</div>
</div>
<div>First, I don't see a problem here. "assert" is a
standard C
feature, and I consider it to be good enough. "Good enough" is
defined
as being a debugging aid for trapping and enforcing preconditions that
can be disabled in a production build of the code.</div>
<div><br>
</div>
<div>I don't like the suggestions proposed for a few
reasons:</div>
<div><br>
</div>
<div>1. Introducing weird macros for assertion checking is another
barrier to learning the code, therefore they should either be really
obvious or provide significant-enough value to make them worth the
barrier.</div>
<div><br>
</div>
<div>2. I don't see the goal of assertions to make it so you
don't
have to debug problems in a debugger. If that's the value of any
change here, then I don't see it being worth the cost.</div>
<div><br>
</div>
<div>3. I don't want to bloat production builds with raw ostream
stuff. This can be solved depending on how the macro is designed, I'm
just sayin'. :)</div>
<div><br>
</div>
<div>Custom assertion macros are nothing new, there is a reason
LLVM hasn't used them until now.</div>
</div>
</blockquote>
<div><br>
</div>
<div>Understood. Here's my final word on the matter: From the
perspective of a user of LLVM's APIs, assertions are the primary
feedback mechanism that tell me whether I am using those APIs
correctly. In the time I've been using LLVM, I've made hundreds if not
thousands of errors - from various causes ranging from simple typos to
of misunderstanding the documentation. (As part of migrating my
frontend to the new type system, I've encountered about a dozen
assertion failures, most of which were quite easy to diagnose once I
knew what type was involved.) Most of the time an assertion failure is
the first signal that I've done something wrong. Unfortunately,
"something went wrong" is about all the information I typically get
from an assertion failure.</div>
</div>
</blockquote>
Although it sounds like a decision may have already been reached on
this, I have to agree with Talin, having custom assertions would make
life easier. <br>
<br>
I think the overly simplistic assertion failures that can require the
user to continually jump in and out of a debugger is a greater barrier
to learning than the slight code bloat and introduction of assertion
macros. If the only users we want to use the LLVM API are those that
are proficient with a debugger and willing to persevere with the
somewhat slower learning curve simple asserts provide (despite
generally excellent documentation I might add), then that's fine.<br>
<br>
Aside from the new user experience, they would also speed up general
development and while it may only be in the most trivial cases that
this proves useful, these cases are also the most common. The majority
of my mistakes would be immediately obvious if I just knew the type or
even which argument was causing the assertion to fire. Most of which
could probably be provided by extending just a handful of the existing
assert calls in the codebase. It's frustrating not to have that
information offered when it is so easily available.<br>
<br>
I'm not going to comment on the syntax of any of the proposals made,
just dispute that they don't provide sufficient value to make them
worth introducing.<br>
<br>
Dan<br>
<blockquote
cite="mid:CABwJDdmR-YZEkMiX0DK7caJhjr7kR_ihHgkX5hn7gaMQhJRyKw@mail.gmail.com"
type="cite">-- <br>
-- Talin<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated"
href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext"
href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext"
href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
</body>
</html>