<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>(A==B)==(X==Y)</title><link>http://blogs.msdn.com/b/jmstall/archive/2007/09/20/a-b-x-y.aspx</link><description>I used to hate the expression: (A==B)==(X==Y), but I've grown very fond of it. My prior feelings of contempt stem from my desire to avoid obscure language features. But I figure when properly parenthesized, this isn't so obscure and can be pretty useful</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: (A==B)==(X==Y)</title><link>http://blogs.msdn.com/b/jmstall/archive/2007/09/20/a-b-x-y.aspx#5035020</link><pubDate>Fri, 21 Sep 2007 19:09:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5035020</guid><dc:creator>Jonathan Perret</dc:creator><description>&lt;p&gt;Until VB.NET, VB still had the Eqv boolean operator. Which allowed you to write :&lt;/p&gt;
&lt;p&gt; (A=B) Eqv (X=Y)&lt;/p&gt;
&lt;p&gt;The result being strictly the same but perhaps slightly more readable ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5035020" width="1" height="1"&gt;</description></item><item><title>re: (A==B)==(X==Y)</title><link>http://blogs.msdn.com/b/jmstall/archive/2007/09/20/a-b-x-y.aspx#5034410</link><pubDate>Fri, 21 Sep 2007 17:58:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5034410</guid><dc:creator>Mike Stall - MSFT</dc:creator><description>&lt;p&gt;I should have been clearer, when I said:&lt;/p&gt;
&lt;p&gt;&amp;quot;This asserts that either you have a pointer to a non-zero-length buffer or you don't have anything at all.&amp;quot;&lt;/p&gt;
&lt;p&gt;Lots of functions tend to take a buffer as (pointer, size), and optionally allow the buffer to be empty. (Eg, maybe it will write something to the buffer if provided).&lt;/p&gt;
&lt;p&gt;How do you supply an empty buffer? Just a null pointer? Just a 0 size? To be defensive, it's nice to require both pBuffer == NULL and cbLength == NULL.&lt;/p&gt;
&lt;p&gt;So then you have 2 valid options:&lt;/p&gt;
&lt;p&gt;pBuffer == NULL &amp;amp;&amp;amp; cbLength == NULL; // empty buffer&lt;/p&gt;
&lt;p&gt;pBuffer != NULL &amp;amp;&amp;amp; cbLength != NULL; // valid buffer&lt;/p&gt;
&lt;p&gt;Rather than assert&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Assert((pBuffer == NULL &amp;amp;&amp;amp; cbLength == NULL) ||&lt;/p&gt;
&lt;p&gt;(pBuffer != NULL &amp;amp;&amp;amp; cbLength != NULL));&lt;/p&gt;
&lt;p&gt;I think it's easy to say&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Assert((pBuffer == NULL) == (cbLength == NULL));&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5034410" width="1" height="1"&gt;</description></item><item><title>re: (A==B)==(X==Y)</title><link>http://blogs.msdn.com/b/jmstall/archive/2007/09/20/a-b-x-y.aspx#5027214</link><pubDate>Fri, 21 Sep 2007 10:53:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5027214</guid><dc:creator>Alois Kraus</dc:creator><description>&lt;p&gt;I am no compiler but what about&lt;/p&gt;
&lt;p&gt;pBuffer = NULL and cbLength = NULL?&lt;/p&gt;
&lt;p&gt;Assert((true) == (true));&lt;/p&gt;
&lt;p&gt;Assert(true); // nothing happens althouth the input is bad.&lt;/p&gt;
&lt;p&gt;If I read this right it will slip through your Assert.&lt;/p&gt;
&lt;p&gt;Yours,&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Alois Kraus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5027214" width="1" height="1"&gt;</description></item></channel></rss>