<?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>alecmce.com &#187; mutable</title>
	<atom:link href="http://alecmce.com/tag/mutable/feed" rel="self" type="application/rss+xml" />
	<link>http://alecmce.com</link>
	<description></description>
	<lastBuildDate>Fri, 18 May 2012 02:54:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>XML Constants Gotcha</title>
		<link>http://alecmce.com/as3/xml-constants-gotcha</link>
		<comments>http://alecmce.com/as3/xml-constants-gotcha#comments</comments>
		<pubDate>Thu, 13 Aug 2009 12:11:03 +0000</pubDate>
		<dc:creator>alecmce</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[gotcha]]></category>
		<category><![CDATA[const]]></category>
		<category><![CDATA[mutable]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://alecmce.com/?p=259</guid>
		<description><![CDATA[In my head, XML slips between the cracks of being an Object and a primitive type. It shouldn&#8217;t, and when I&#8217;m concentrated it doesn&#8217;t. But still, there is something primitive-type about it. and are intuitively the same sorts of things. XML is like an advanced sort of String. We encode it as we encode text, [...]]]></description>
			<content:encoded><![CDATA[<p>In my head, XML slips between the cracks of being an Object and a primitive type. It shouldn&#8217;t, and when I&#8217;m concentrated it doesn&#8217;t. But still, there is something primitive-type about it.</p>
<pre class="brush: as3; title: ; notranslate">private const DATA:XML = &lt;data message=&quot;Hello World!&quot; /&gt;;</pre>
<p>and</p>
<pre class="brush: as3; first-line: 2; title: ; notranslate">private const DATA:String = &quot;Hello World!&quot;;</pre>
<p>are intuitively the same sorts of things. XML is like an advanced sort of String. We encode it as we encode text, and we convert it to and from Strings without difficulty. I don&#8217;t construct XML, at least it doesn&#8217;t <em>feel</em> like I do. In my preferred coding environment (<a href="http://fdt.powerflasher.com/">FDT</a>) by default they&#8217;re even similarly coloured.</p>
<p>However, they are clearly not the same, because XML is mutable:</p>
<pre class="brush: as3; first-line: 3; title: ; notranslate">DATA.@message = &quot;This message has been changed!&quot;;</pre>
<p>Needless to say, that doesn&#8217;t work on a String! Somehow by labelling the XML a &#8216;constant&#8217; I expect the XML to be immutable.</p>
<p>On reflection I know this about XML, but it <em>feels</em> wrong. This &#8216;gotcha&#8217; does not identify a language bug, but suggests a mental corrective: when you think about XML, make sure that you don&#8217;t mistake it for a primitive type. When I&#8217;m not concentrating I do, and it occassionally trips me up.</p>
]]></content:encoded>
			<wfw:commentRss>http://alecmce.com/as3/xml-constants-gotcha/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

