<?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: More on iteration</title>
	<atom:link href="http://blog.iconara.net/2006/09/30/more-on-iteration/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.iconara.net/2006/09/30/more-on-iteration/</link>
	<description></description>
	<lastBuildDate>Mon, 07 Nov 2011 12:03:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Theo</title>
		<link>http://blog.iconara.net/2006/09/30/more-on-iteration/comment-page-1/#comment-4398</link>
		<dc:creator>Theo</dc:creator>
		<pubDate>Wed, 30 May 2007 11:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.iconara.net/2006/09/30/more-on-iteration/#comment-4398</guid>
		<description>&lt;p&gt;I agree that list.map(fn) is more readable than map(fn, list). Unfortunately the solution presented in the articles you link to rely on adding things to the prototype of library classes, which is not a good idea. It leads to prototype pollution and even less readable code in the larger perspective.&lt;/p&gt;

&lt;p&gt;The problem is that if you don&#039;t know that Array&#039;s prototype has been patched to include map, filter and each you have no idea what&#039;s happening. Moreover, what if two different libraries both patch Array to include a map method, but use different and incompatible implementations? (different parameter order, for example). This is the reason why none of the major Ajax libraries use prototype patching.&lt;/p&gt;

&lt;p&gt;In ActionScript there is also the added problem of when the patches are applied, you have to make sure that they are applied before you try to use the methods they add (by including them in frame 1, for example). Otherwise you will get bugs that are extremely hard to find.&lt;/p&gt;

&lt;p&gt;When I started programming in ActionScript I extended Array, Object and some of the other core classes to include the functionality I needed. But I started noticing that it was harder for me to reuse code that way. I would start a new project, decide that a part of it was very similar to something I had done in another project, include that code, compile and run. And it would not work the way it should. The reason (which is obvious in hindsight, but not there and then) was that the code I had brought over from the other project used my patches, but I had not yet included them in the new project for various reasons. The code would compile fine because to use the patched methods you can&#039;t type your variables, and then you don&#039;t get warnings for non-existent functions. However, when the code runs the methods don&#039;t exist and no runtime errors are raised, the code just continues. This is a really hopeless thing to debug.&lt;/p&gt;

&lt;p&gt;The irony in this is that the reason why JavaScript has prototypes is to support this kind of patching of the core classes. In the end it turned out that for other uses than very simple scripts it wasn&#039;t such a good idea, and more of a problem than a solution.&lt;/p&gt;

&lt;p&gt;The good news is that in ActionScript 3 the Array class includes map, filter and each.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I agree that list.map(fn) is more readable than map(fn, list). Unfortunately the solution presented in the articles you link to rely on adding things to the prototype of library classes, which is not a good idea. It leads to prototype pollution and even less readable code in the larger perspective.</p>

<p>The problem is that if you don&#8217;t know that Array&#8217;s prototype has been patched to include map, filter and each you have no idea what&#8217;s happening. Moreover, what if two different libraries both patch Array to include a map method, but use different and incompatible implementations? (different parameter order, for example). This is the reason why none of the major Ajax libraries use prototype patching.</p>

<p>In ActionScript there is also the added problem of when the patches are applied, you have to make sure that they are applied before you try to use the methods they add (by including them in frame 1, for example). Otherwise you will get bugs that are extremely hard to find.</p>

<p>When I started programming in ActionScript I extended Array, Object and some of the other core classes to include the functionality I needed. But I started noticing that it was harder for me to reuse code that way. I would start a new project, decide that a part of it was very similar to something I had done in another project, include that code, compile and run. And it would not work the way it should. The reason (which is obvious in hindsight, but not there and then) was that the code I had brought over from the other project used my patches, but I had not yet included them in the new project for various reasons. The code would compile fine because to use the patched methods you can&#8217;t type your variables, and then you don&#8217;t get warnings for non-existent functions. However, when the code runs the methods don&#8217;t exist and no runtime errors are raised, the code just continues. This is a really hopeless thing to debug.</p>

<p>The irony in this is that the reason why JavaScript has prototypes is to support this kind of patching of the core classes. In the end it turned out that for other uses than very simple scripts it wasn&#8217;t such a good idea, and more of a problem than a solution.</p>

<p>The good news is that in ActionScript 3 the Array class includes map, filter and each.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Baker</title>
		<link>http://blog.iconara.net/2006/09/30/more-on-iteration/comment-page-1/#comment-4397</link>
		<dc:creator>Andy Baker</dc:creator>
		<pubDate>Wed, 30 May 2007 08:23:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.iconara.net/2006/09/30/more-on-iteration/#comment-4397</guid>
		<description>&lt;p&gt;I much prefer the dot syntax to the function version as it&#039;s much more readable and seems to match the way my brain sees the problem (could that be because it&#039;s in subject-verb order like English?)&lt;/p&gt;

&lt;p&gt;You say it can&#039;t be done but it can by injecting methods into the object and array classes. I wasn&#039;t clever enough to actually write the code but this chap was:
http://www.rocketboots.com.au/blog/index.cfm?mode=entry&amp;entry=A5C356B1-E081-51EF-A79F47A1601ADEDF
(the first article referred to is here: http://www.rocketboots.com.au/blog/index.cfm?mode=entry&amp;entry=A046CDD7-E081-51EF-A7890B1753F05472 )&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I much prefer the dot syntax to the function version as it&#8217;s much more readable and seems to match the way my brain sees the problem (could that be because it&#8217;s in subject-verb order like English?)</p>

<p>You say it can&#8217;t be done but it can by injecting methods into the object and array classes. I wasn&#8217;t clever enough to actually write the code but this chap was:
<a href="http://www.rocketboots.com.au/blog/index.cfm?mode=entry&amp;entry=A5C356B1-E081-51EF-A79F47A1601ADEDF" rel="nofollow">http://www.rocketboots.com.au/blog/index.cfm?mode=entry&amp;entry=A5C356B1-E081-51EF-A79F47A1601ADEDF</a>
(the first article referred to is here: <a href="http://www.rocketboots.com.au/blog/index.cfm?mode=entry&amp;entry=A046CDD7-E081-51EF-A7890B1753F05472" rel="nofollow">http://www.rocketboots.com.au/blog/index.cfm?mode=entry&amp;entry=A046CDD7-E081-51EF-A7890B1753F05472</a> )</p>]]></content:encoded>
	</item>
</channel>
</rss>

