<?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: Compile-Time Constants</title>
	<atom:link href="http://jacksondunstan.com/articles/468/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/468</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Mon, 14 May 2012 17:02:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: c1</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-25737</link>
		<dc:creator>c1</dc:creator>
		<pubDate>Sat, 31 Mar 2012 07:00:10 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-25737</guid>
		<description>I thought that you would like to know that you can in fact define constants from within an Actionscript file.

&lt;pre lang=&quot;actionscript3&quot;&gt;
config namespace MY_NAMESPACE;
MY_NAMESPACE const CONST_1 = true;
MY_NAMESPACE const CONST_2 = true;
&lt;/pre&gt;

See this link for more information :
http://wiki.ecmascript.org/doku.php?id=proposals:program_configuration</description>
		<content:encoded><![CDATA[<p>I thought that you would like to know that you can in fact define constants from within an Actionscript file.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">config <span style="color: #004993;">namespace</span> MY_NAMESPACE<span style="color: #000066; font-weight: bold;">;</span>
MY_NAMESPACE const CONST_1 = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
MY_NAMESPACE const CONST_2 = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>See this link for more information :<br />
<a href="http://wiki.ecmascript.org/doku.php?id=proposals:program_configuration" rel="nofollow">http://wiki.ecmascript.org/doku.php?id=proposals:program_configuration</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-741</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Thu, 22 Jul 2010 22:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-741</guid>
		<description>A deal breaker for using FDT or compile-time constants? Even with the annoyance of FDT_IGNORE, compile-time constants can have huge payoffs in very hot areas of the code that may outweigh the inconvenience.</description>
		<content:encoded><![CDATA[<p>A deal breaker for using FDT or compile-time constants? Even with the annoyance of FDT_IGNORE, compile-time constants can have huge payoffs in very hot areas of the code that may outweigh the inconvenience.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Bilyk</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-740</link>
		<dc:creator>Nick Bilyk</dc:creator>
		<pubDate>Thu, 22 Jul 2010 21:14:46 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-740</guid>
		<description>FDT&#039;s lack of conditional compilation argument support is a deal breaker for me.   FDT_IGNORE tags are problematic for obvious reasons.</description>
		<content:encoded><![CDATA[<p>FDT&#8217;s lack of conditional compilation argument support is a deal breaker for me.   FDT_IGNORE tags are problematic for obvious reasons.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-396</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Wed, 18 Nov 2009 23:49:59 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-396</guid>
		<description>You&#039;re right, too. :) None of this would be necessary if the compiler just inlined constants for you. Instead, &lt;tt&gt;const&lt;/tt&gt; is just a synonym for &lt;tt&gt;var&lt;/tt&gt; other than some error checking to make sure you don&#039;t inadvertently change the value. Maybe in a future version of MXMLC they&#039;ll address this and we can get rid of workarounds like these.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, too. :) None of this would be necessary if the compiler just inlined constants for you. Instead, <tt>const</tt> is just a synonym for <tt>var</tt> other than some error checking to make sure you don&#8217;t inadvertently change the value. Maybe in a future version of MXMLC they&#8217;ll address this and we can get rid of workarounds like these.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alec McEachran</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-395</link>
		<dc:creator>Alec McEachran</dc:creator>
		<pubDate>Wed, 18 Nov 2009 23:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-395</guid>
		<description>You&#039;re right, of course. Sorry for making my point so clumsily, and thanks for the tip John.

I suppose my main gripe is to do with the compiler; I hate to see code readability sacrificed for compilation issues. Compiler&#039;s should be artful enough to sort this out without workarounds.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, of course. Sorry for making my point so clumsily, and thanks for the tip John.</p>
<p>I suppose my main gripe is to do with the compiler; I hate to see code readability sacrificed for compilation issues. Compiler&#8217;s should be artful enough to sort this out without workarounds.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-394</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Wed, 18 Nov 2009 18:11:56 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-394</guid>
		<description>Speed definitely ain&#039;t everything, which is why I bothered to point out the annoyance caused by having your constants outside of the AS3 source. However, I think you could mask this pretty well since the constants you define are actually AS3 code that is simply evaluated at compile time. For example, you can easily have a simple name-value pair file that is read in as an Ant properties file. Here&#039;s an example math.properties:

&lt;pre lang=&quot;text&quot;&gt;
pi=3.14159265
e=2.71828183
sqrt2=1.41421356
&lt;/pre&gt;

This should be understandable by any programmer (or non-programmer) but still, as you point out, it&#039;s something &quot;special&quot; that a newbie would have to learn. I think that, for a one-minute lecture on where the constants are and why, the payoff is huge! Integrating it into an Ant build should be easy too:

&lt;pre lang=&quot;xml&quot;&gt;
&lt;property file=&quot;math.properties&quot;/&gt;
...
&lt;exec executable=&quot;mxmlc&quot;&gt;
	&lt;arg line=&quot;-define=MATH::pi,${pi}&quot; /&gt;
	&lt;arg line=&quot;-define=MATH::e,${e}&quot; /&gt;
	&lt;arg line=&quot;-define=MATH::sqrt2,${sqrt2}&quot; /&gt;
	...
&lt;/exec&gt;
&lt;/pre&gt;

To me it seems like, in the grand scheme of a project, a quibble. Of course everyone is free to decide for themselves just how big of a deal this is for their project.</description>
		<content:encoded><![CDATA[<p>Speed definitely ain&#8217;t everything, which is why I bothered to point out the annoyance caused by having your constants outside of the AS3 source. However, I think you could mask this pretty well since the constants you define are actually AS3 code that is simply evaluated at compile time. For example, you can easily have a simple name-value pair file that is read in as an Ant properties file. Here&#8217;s an example math.properties:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pi=3.14159265
e=2.71828183
sqrt2=1.41421356</pre></div></div>

<p>This should be understandable by any programmer (or non-programmer) but still, as you point out, it&#8217;s something &#8220;special&#8221; that a newbie would have to learn. I think that, for a one-minute lecture on where the constants are and why, the payoff is huge! Integrating it into an Ant build should be easy too:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;math.properties&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;mxmlc&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-define=MATH::pi,${pi}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-define=MATH::e,${e}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-define=MATH::sqrt2,${sqrt2}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    ...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>To me it seems like, in the grand scheme of a project, a quibble. Of course everyone is free to decide for themselves just how big of a deal this is for their project.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Lindquist</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-393</link>
		<dc:creator>John Lindquist</dc:creator>
		<pubDate>Wed, 18 Nov 2009 12:41:48 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-393</guid>
		<description>@Alec - if you&#039;re using FDT, wrap compiler constants with /*FDT_IGNORE*/ to make the errors disappear.</description>
		<content:encoded><![CDATA[<p>@Alec &#8211; if you&#8217;re using FDT, wrap compiler constants with /*FDT_IGNORE*/ to make the errors disappear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alec McEachran</title>
		<link>http://jacksondunstan.com/articles/468/comment-page-1#comment-392</link>
		<dc:creator>Alec McEachran</dc:creator>
		<pubDate>Wed, 18 Nov 2009 09:36:09 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=468#comment-392</guid>
		<description>I thought this is where you were going, Jackson ;) Thanks for the thorough analysis, though.

I disagree with you though that a lack of #define is a quibble. A major concern of mine is that code should be as readable as possible. Although a constant name should be readable in itself, in this case the constant&#039;s value is separated from the code into a command line argument. If the constant was the sort of thing that migth be tweaked from time to time (unlike PI!); how do I go about changing that? If I&#039;m a coder new to the project, how do I find it? It adds a layer of complexity that I dislike.

Annoyingly too, if you&#039;re using FDT (and probably other editors) you&#039;ll litter your code with errors making discerning the real errors harder to discern and devaluing the tool.

It is good to know about, but I don&#039;t like it because of these concerns. Speed ain&#039;t everything!</description>
		<content:encoded><![CDATA[<p>I thought this is where you were going, Jackson ;) Thanks for the thorough analysis, though.</p>
<p>I disagree with you though that a lack of #define is a quibble. A major concern of mine is that code should be as readable as possible. Although a constant name should be readable in itself, in this case the constant&#8217;s value is separated from the code into a command line argument. If the constant was the sort of thing that migth be tweaked from time to time (unlike PI!); how do I go about changing that? If I&#8217;m a coder new to the project, how do I find it? It adds a layer of complexity that I dislike.</p>
<p>Annoyingly too, if you&#8217;re using FDT (and probably other editors) you&#8217;ll litter your code with errors making discerning the real errors harder to discern and devaluing the tool.</p>
<p>It is good to know about, but I don&#8217;t like it because of these concerns. Speed ain&#8217;t everything!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

