<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JulioBiason.Net &#187; nothing</title>
	<atom:link href="http://juliobiason.net/tag/nothing/feed/" rel="self" type="application/rss+xml" />
	<link>http://juliobiason.net</link>
	<description>Old-school coder living in a 2.0 development world.</description>
	<lastBuildDate>Mon, 30 Aug 2010 11:55:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The multiple faces of nothing</title>
		<link>http://juliobiason.net/2008/10/23/the-multiple-faces-of-nothing/</link>
		<comments>http://juliobiason.net/2008/10/23/the-multiple-faces-of-nothing/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 00:43:22 +0000</pubDate>
		<dc:creator>Julio Biason</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[nil]]></category>
		<category><![CDATA[nothing]]></category>
		<category><![CDATA[nsnull]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://juliobiason.net/?p=1880</guid>
		<description><![CDATA[[... or "C, variants and the NULL"] In C, you have a way to represent nothing. It&#8217;s NULL (all caps). NULL points to nowhere and it&#8217;s defined as &#8220;0&#8243;. Why would someone use it? Well, if you have a list &#8230; <a href="http://juliobiason.net/2008/10/23/the-multiple-faces-of-nothing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>[... or "C, variants and the NULL"]</p>
<p>In C, you have a way to represent nothing. It&#8217;s NULL (all caps). NULL points to nowhere and it&#8217;s defined as &#8220;0&#8243;. Why would someone use it? Well, if you have a list and some of the elements aren&#8217;t valid, you make them NULL. Since NULL is not a valid pointer, your application will crash if you try to access it. The whole point of NULL is to provide a way to represent the nothing. There is also a nothing type &#8220;void&#8221;, which you can define anything statically, but you can make it a point of it. Since all pointers have the same size, a &#8220;void pointer&#8221; is, basically, a pointer to anything.</p>
<p>Also, C have the idea of &#8220;nul-terminated strings&#8221; (yes, with just one &#8220;l&#8221;.) the &#8220;nul&#8221; character is represented by &#8220;\0&#8243;, which, in practical terms, is a space of memory with the size of a &#8220;char&#8221; with the value 0 on it.</p>
<p>When going down to the very bits of NULL and nul, they go almost the same, except for their size.</p>
<p>C++ was build on top of C, but if defined NULL as a pointer pointing to the byte 0. It&#8217;s almost the same thing as the C NULL but, because it&#8217;s a pointer, it doesn&#8217;t need to be converted when you&#8217;re using a CPU which have a different size for &#8220;int&#8221;s and pointers (usually, pointers are &#8220;long int&#8221;s or even more, if your CPU have more than 64 bits.)</p>
<p>Objective-C is a variant of C adding support for objects in a different way and the biggest &#8220;user&#8221; of Objective-C is Apple. The Apple version of Objective-C provides some basic types like lists. But, because you can&#8217;t leave an empty space in the list (which I think it similar to the way we deal with nul-terminated string), they created a NSNull object, which is a valid object, but it represents the null (which, by the way, are called &#8220;nil&#8221; in Objective-C.) It&#8217;s <em>not</em> an invalid memory address, as it points to a real object. The NSNull object provides just one method, &#8220;null&#8221; which returns a &#8220;nil&#8221; pointer (are you confused already?)</p>
<p>Now, the fun part: Most list (dictionaries actually, but the process is almost the same) operations, when you try to access an object that doesn&#8217;t exist, returns nil. But remember that the only way to leave an empty spot in a list is adding a NSNull object. So, to be really sure that something is not there, you need to check if the result is &#8220;nil&#8221; or &#8220;not an [NSNull null]&#8220;.</p>
<p>That&#8217;s too much stuff for nothing&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://juliobiason.net/2008/10/23/the-multiple-faces-of-nothing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
