<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.12-alpha" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: .NET is an endless supply of fascinating puzzles</title>
	<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles</link>
	<description>What happens at LShift</description>
	<pubDate>Fri, 21 Nov 2008 20:41:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.12-alpha</generator>

	<item>
		<title>by: tonyg</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-67526</link>
		<pubDate>Fri, 05 Oct 2007 10:58:32 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-67526</guid>
					<description>&lt;p&gt;Rik, I'm not talking about indexes - I'm talking about the array size itself. Also, the bounds check would be 0 &#60;= index &#60; sizeof(array), rather than 0 &#60;= index &#60;= sizeof(array). An array of size zero is empty, and indexing it at all is an error.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Rik, I&#8217;m not talking about indexes - I&#8217;m talking about the array size itself. Also, the bounds check would be 0 &lt;= index &lt; sizeof(array), rather than 0 &lt;= index &lt;= sizeof(array). An array of size zero is empty, and indexing it at all is an error.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Rik Rose</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-67524</link>
		<pubDate>Fri, 05 Oct 2007 09:55:35 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-67524</guid>
					<description>&lt;p&gt;There's several views this could take, on first reading. Not knowing C# yet, I must confess that I don't know the actual answer.&lt;/p&gt;

&lt;p&gt;Given a negative index, there are two sensible things that I can see the langauge doing.&lt;/p&gt;

&lt;p&gt;Firstly, it could perform a bounds check on 0 &#60;= index &#60;= sizeof(array), and throwing an error if it's out of bounds.&lt;/p&gt;

&lt;p&gt;Secondly, it could perform a bounds check on abs(index) &#60;= sizeof(array), and then work backwards from the end, if index &#60; 0. This is what Ruby does.&lt;/p&gt;

&lt;p&gt;I would hazard a guess that option 2 would not have been seen to be as helpful as possible, and so option 1 is what I would expect to happen.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>There&#8217;s several views this could take, on first reading. Not knowing C# yet, I must confess that I don&#8217;t know the actual answer.</p>
<p>Given a negative index, there are two sensible things that I can see the langauge doing.</p>
<p>Firstly, it could perform a bounds check on 0 &lt;= index &lt;= sizeof(array), and throwing an error if it&#8217;s out of bounds.</p>
<p>Secondly, it could perform a bounds check on abs(index) &lt;= sizeof(array), and then work backwards from the end, if index &lt; 0. This is what Ruby does.</p>
<p>I would hazard a guess that option 2 would not have been seen to be as helpful as possible, and so option 1 is what I would expect to happen.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: tonyg</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66385</link>
		<pubDate>Thu, 20 Sep 2007 11:36:58 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66385</guid>
					<description>&lt;p&gt;Paul, you are indeed too kind.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Paul, you are indeed too kind.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Paul Crowley</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66380</link>
		<pubDate>Thu, 20 Sep 2007 11:11:25 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66380</guid>
					<description>&lt;p&gt;Being maximally generous I can only imagine something like this:&lt;/p&gt;

&lt;p&gt;o = new objectCache();&lt;/p&gt;

&lt;p&gt;o.maxArraySize = -1; // Disallow all array creation&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Being maximally generous I can only imagine something like this:</p>
<p>o = new objectCache();</p>
<p>o.maxArraySize = -1; // Disallow all array creation</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: tonyg</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66370</link>
		<pubDate>Thu, 20 Sep 2007 11:01:32 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66370</guid>
					<description>&lt;p&gt;Matthew, that's an excellent point! If I were being serious, I'd say something along the lines of "clearly choosing a fixed representation for array lengths (and in fact arrays) is a case of premature optimisation"... but since I'm not, I'll suggest that what C# &lt;i&gt;really&lt;/i&gt; needs is a dependent type system.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Matthew, that&#8217;s an excellent point! If I were being serious, I&#8217;d say something along the lines of &#8220;clearly choosing a fixed representation for array lengths (and in fact arrays) is a case of premature optimisation&#8221;&#8230; but since I&#8217;m not, I&#8217;ll suggest that what C# <i>really</i> needs is a dependent type system.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: matthew</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66362</link>
		<pubDate>Thu, 20 Sep 2007 08:02:11 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66362</guid>
					<description>&lt;p&gt;Hang on, if you follow this route too far then you'll end up wanting different sizes of ints depending on the amount of memory available at runtime - after all, if you've only got 32MB of RAM available then the type of the number should not allow values greater than 33554432. But this should also take into account the size of the values in the array - if they're just bools and they're bit-packed, then 33554432 won't be too bad. But if they're large objects, then a limit rather lower is needed...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hang on, if you follow this route too far then you&#8217;ll end up wanting different sizes of ints depending on the amount of memory available at runtime - after all, if you&#8217;ve only got 32MB of RAM available then the type of the number should not allow values greater than 33554432. But this should also take into account the size of the values in the array - if they&#8217;re just bools and they&#8217;re bit-packed, then 33554432 won&#8217;t be too bad. But if they&#8217;re large objects, then a limit rather lower is needed&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Alex Blewitt</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66316</link>
		<pubDate>Wed, 19 Sep 2007 18:11:56 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66316</guid>
					<description>&lt;p&gt;It's so that there's backward compatibility for all those buffer underflows that viruses have come to rely on&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It&#8217;s so that there&#8217;s backward compatibility for all those buffer underflows that viruses have come to rely on</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: tonyg</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66309</link>
		<pubDate>Wed, 19 Sep 2007 17:10:38 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66309</guid>
					<description>&lt;p&gt;Well that certainly sounds complex.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Well that certainly sounds complex.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Neil Bartlett</title>
		<link>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66300</link>
		<pubDate>Wed, 19 Sep 2007 13:41:21 +0000</pubDate>
		<guid>http://www.lshift.net/blog/2007/09/19/net-is-an-endless-supply-of-fascinating-puzzles#comment-66300</guid>
					<description>&lt;p&gt;Imaginary arrays...?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Imaginary arrays&#8230;?</p>
]]></content:encoded>
				</item>
</channel>
</rss>
