<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Proposal: generics (and some other stuff) for Objective-C</title>
	<atom:link href="http://jens.ayton.se/blag/generics-for-objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://jens.ayton.se/blag/generics-for-objective-c/</link>
	<description>Cocoa coding stuff, when I can be bothered.</description>
	<lastBuildDate>Mon, 28 Jun 2010 19:09:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Jens Ayton</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-290</link>
		<dc:creator>Jens Ayton</dc:creator>
		<pubDate>Mon, 28 Jun 2010 19:09:33 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-290</guid>
		<description>It wouldn’t break supersetosity if &lt;code&gt;var&lt;/code&gt; could be redefined, somewhat analogous to the way &lt;code&gt;self&lt;/code&gt; can be used in non-method contexts. But that would cause new problems, so I agree – an @-keyword would be better, yet uglier. (It could perhaps be defined to a normal identifier in a standard header, just as &lt;code&gt;id&lt;/code&gt; is typedefed, or &lt;code&gt;bool&lt;/code&gt; is in C99.)</description>
		<content:encoded><![CDATA[<p>It wouldn’t break supersetosity if <code>var</code> could be redefined, somewhat analogous to the way <code>self</code> can be used in non-method contexts. But that would cause new problems, so I agree – an @-keyword would be better, yet uglier. (It could perhaps be defined to a normal identifier in a standard header, just as <code>id</code> is typedefed, or <code>bool</code> is in C99.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ondra Hošek</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-289</link>
		<dc:creator>Ondra Hošek</dc:creator>
		<pubDate>Mon, 28 Jun 2010 18:56:08 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-289</guid>
		<description>I might be a bit late to the fray, but calling the infer-me type &quot;var&quot; would break ObjC&#039;s strict-superset-ness, since I&#039;d not be able to declare an &quot;int var;&quot; anymore. This is very probably the reason why every ObjC keyword is prefixed with an @ sign.</description>
		<content:encoded><![CDATA[<p>I might be a bit late to the fray, but calling the infer-me type &#8220;var&#8221; would break ObjC&#8217;s strict-superset-ness, since I&#8217;d not be able to declare an &#8220;int var;&#8221; anymore. This is very probably the reason why every ObjC keyword is prefixed with an @ sign.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Ayton</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-269</link>
		<dc:creator>Jens Ayton</dc:creator>
		<pubDate>Mon, 16 Nov 2009 23:16:09 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-269</guid>
		<description>“…add this metadata to the interface” is a good phrase. Every now and then, I read or write code like:

&lt;code&gt;- (NSArray *) frobs; // Array of JAFrob&lt;/code&gt;

This is suboptimal for – once again – exactly the same reason &lt;code&gt;- (id) frobs; // NSArray of JAFrob&lt;/code&gt; would be. The genericized form, &lt;code&gt;- (NSArray[JAFrob] *) frobs;&lt;/code&gt; gives you the whole scoop in one place consistently with non-container methods.</description>
		<content:encoded><![CDATA[<p>“…add this metadata to the interface” is a good phrase. Every now and then, I read or write code like:</p>
<p><code>- (NSArray *) frobs; // Array of JAFrob</code></p>
<p>This is suboptimal for – once again – exactly the same reason <code>- (id) frobs; // NSArray of JAFrob</code> would be. The genericized form, <code>- (NSArray[JAFrob] *) frobs;</code> gives you the whole scoop in one place consistently with non-container methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-268</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Mon, 16 Nov 2009 23:07:23 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-268</guid>
		<description>I had a list of things to put after that sentence, but I decided not to; everything there could be argued against with something that could be answered with that sentence. (For better or worse.) Now I&#039;m going to spell it out anyway, though, since we really may not be on the same page.

*Usually*, the temporary variable is not a problem. You&#039;re right that it&#039;s not the end of the world. Sometimes you end up with treacherous pairs. `length` exists on both NSString and on NSData, and `count` on a bunch of different collections. (They happen to have the same semantics, but that&#039;s not why they&#039;re treacherous, it&#039;s because they block the compiler warning or error from happening.)

In some cases you change a data type somewhere and the code you used for removing/enumerating objects from one collection and inserting into another either doesn&#039;t do any logic on the object or happens to do the exact operation that&#039;s sort of available on both, and you end up pushing an object of the entirely wrong kind of class somewhere else, and you have to go hunt for the bug.

Like Ayton said, ask yourself again why you use the temporary variable. Casting (or even just plain assignment) certainly doesn&#039;t convert the object or throw if it fails. It&#039;s there for documentation for your eyes, and to enable Code Sense. If that can be done with fewer lines of code, help keep the variables down to the ones you actually want to have around and last but not least add this metadata to the interface in the first place (we&#039;ve been talking about implementation), I don&#039;t see why it&#039;s not worthwhile.</description>
		<content:encoded><![CDATA[<p>I had a list of things to put after that sentence, but I decided not to; everything there could be argued against with something that could be answered with that sentence. (For better or worse.) Now I&#8217;m going to spell it out anyway, though, since we really may not be on the same page.</p>
<p>*Usually*, the temporary variable is not a problem. You&#8217;re right that it&#8217;s not the end of the world. Sometimes you end up with treacherous pairs. `length` exists on both NSString and on NSData, and `count` on a bunch of different collections. (They happen to have the same semantics, but that&#8217;s not why they&#8217;re treacherous, it&#8217;s because they block the compiler warning or error from happening.)</p>
<p>In some cases you change a data type somewhere and the code you used for removing/enumerating objects from one collection and inserting into another either doesn&#8217;t do any logic on the object or happens to do the exact operation that&#8217;s sort of available on both, and you end up pushing an object of the entirely wrong kind of class somewhere else, and you have to go hunt for the bug.</p>
<p>Like Ayton said, ask yourself again why you use the temporary variable. Casting (or even just plain assignment) certainly doesn&#8217;t convert the object or throw if it fails. It&#8217;s there for documentation for your eyes, and to enable Code Sense. If that can be done with fewer lines of code, help keep the variables down to the ones you actually want to have around and last but not least add this metadata to the interface in the first place (we&#8217;ve been talking about implementation), I don&#8217;t see why it&#8217;s not worthwhile.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Ayton</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-267</link>
		<dc:creator>Jens Ayton</dc:creator>
		<pubDate>Fri, 13 Nov 2009 19:55:42 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-267</guid>
		<description>Well, I certainly can’t beat Jesper at succinctness.

To quote myself: “The idea is to provide information that helps the compiler and analyzer check your logic, and the IDE to provide better suggestions.” Exactly like static typing in general, then.

For example, if I have a heterogeneous dictionary, and type &lt;code&gt;[[someDict objectForKey:key] st&lt;esc&gt;]&lt;/code&gt;, I want relevant suggestions. If I use a method that the value type doesn’t have, I want to be warned about it. If you don’t see these as advantages, why don’t you use &lt;code&gt;id&lt;/code&gt; everywhere?

The “ just sane use of temporary variables” thing sounds to me like you’re desensitized to a workaround.</description>
		<content:encoded><![CDATA[<p>Well, I certainly can’t beat Jesper at succinctness.</p>
<p>To quote myself: “The idea is to provide information that helps the compiler and analyzer check your logic, and the IDE to provide better suggestions.” Exactly like static typing in general, then.</p>
<p>For example, if I have a heterogeneous dictionary, and type <code>[[someDict objectForKey:key] st&lt;esc&gt;]</code>, I want relevant suggestions. If I use a method that the value type doesn’t have, I want to be warned about it. If you don’t see these as advantages, why don’t you use <code>id</code> everywhere?</p>
<p>The “ just sane use of temporary variables” thing sounds to me like you’re desensitized to a workaround.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-266</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Fri, 13 Nov 2009 17:43:03 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-266</guid>
		<description>mike: The types in generics are useful for exactly the same reason the types everywhere else are useful.</description>
		<content:encoded><![CDATA[<p>mike: The types in generics are useful for exactly the same reason the types everywhere else are useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mikeash</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-265</link>
		<dc:creator>mikeash</dc:creator>
		<pubDate>Thu, 12 Nov 2009 23:08:14 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-265</guid>
		<description>I like the contextual types proposal. This sort of thing has been annoying, and occasionally destructive, for quite a while. I hope Apple adopts something like this.

I don&#039;t really get the generics proposal, though. Mistakes due to forgetting what sort of object are in a collection are, in my experience, rare and easily caught. Very, very occasionally you run into problems because -objectAtIndex: returns id and this results in type confusion, but with for/in loops or just sane use of temporary variables this doesn&#039;t really happen. Is there a specific use case beyond this that I&#039;m missing?</description>
		<content:encoded><![CDATA[<p>I like the contextual types proposal. This sort of thing has been annoying, and occasionally destructive, for quite a while. I hope Apple adopts something like this.</p>
<p>I don&#8217;t really get the generics proposal, though. Mistakes due to forgetting what sort of object are in a collection are, in my experience, rare and easily caught. Very, very occasionally you run into problems because -objectAtIndex: returns id and this results in type confusion, but with for/in loops or just sane use of temporary variables this doesn&#8217;t really happen. Is there a specific use case beyond this that I&#8217;m missing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uros Dimitrijevic</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-264</link>
		<dc:creator>Uros Dimitrijevic</dc:creator>
		<pubDate>Sun, 08 Nov 2009 01:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-264</guid>
		<description>Interesting. Sort of like Java generics but with the flexibility of Objective-C. Although one thing that I can&#039;t seem to ignore is the complexity this would add to the language, however negligible its impact would be on backwards-compatibility. 

Oh, and on calling the inferred type &#039;ego&#039;: priceless. (Does that mean I wasn&#039;t mistaken in not pronouncing the &#039;id&#039; type &#039;eye-dee&#039;?)</description>
		<content:encoded><![CDATA[<p>Interesting. Sort of like Java generics but with the flexibility of Objective-C. Although one thing that I can&#8217;t seem to ignore is the complexity this would add to the language, however negligible its impact would be on backwards-compatibility. </p>
<p>Oh, and on calling the inferred type &#8216;ego&#8217;: priceless. (Does that mean I wasn&#8217;t mistaken in not pronouncing the &#8216;id&#8217; type &#8216;eye-dee&#8217;?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joachim Bengtsson</title>
		<link>http://jens.ayton.se/blag/generics-for-objective-c/comment-page-1/#comment-254</link>
		<dc:creator>Joachim Bengtsson</dc:creator>
		<pubDate>Mon, 05 Oct 2009 21:43:17 +0000</pubDate>
		<guid isPermaLink="false">http://jens.ayton.se/blag/?p=78#comment-254</guid>
		<description>I really like it, actually! Then again, I&#039;m starting to warm up to C++ again… Maybe I&#039;m just mad. Really like that &#039;auto&#039; keyword too, that&#039;ll ease C++ coding.</description>
		<content:encoded><![CDATA[<p>I really like it, actually! Then again, I&#8217;m starting to warm up to C++ again… Maybe I&#8217;m just mad. Really like that &#8216;auto&#8217; keyword too, that&#8217;ll ease C++ coding.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
