<?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: Weird CFLOOP Quirk</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Thu, 11 Sep 2014 09:58:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: barneyb</title>
		<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/comment-page-1/#comment-600</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Tue, 28 Nov 2006 16:13:22 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/#comment-600</guid>
		<description>Certainly more readable (though equivalent) is this:

[cfset x = config.MAX_IMAGES_PER_IMPORT / 8 /&gt;
[cfloop condition=&quot;count LT #x#&quot;&gt;

It&#039;s worth mentioning that numbers evaluate to themselves, so you don&#039;t need to DE() them inside an IIF() unless you want to.  Using DE will save you the cost of evaluating the expression if it&#039;s unneeded, but for simple numbers that&#039;s usually not helpful, so you can just use the number directly.</description>
		<content:encoded><![CDATA[<p>Certainly more readable (though equivalent) is this:</p>
<p>[cfset x = config.MAX_IMAGES_PER_IMPORT / 8 /><br />
[cfloop condition="count LT #x#"></p>
<p>It's worth mentioning that numbers evaluate to themselves, so you don't need to DE() them inside an IIF() unless you want to.  Using DE will save you the cost of evaluating the expression if it's unneeded, but for simple numbers that's usually not helpful, so you can just use the number directly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Nadel</title>
		<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/comment-page-1/#comment-599</link>
		<dc:creator>Ben Nadel</dc:creator>
		<pubDate>Tue, 28 Nov 2006 13:56:16 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/#comment-599</guid>
		<description>That is really strange! If you want to get crazy, this works :)

[cfloop condition=&quot;count LT #IIF( true, DE( config.MAX_IMAGES_PER_IMPORT / 8 ), DE(0) )#&quot;]

No need to, but I just wanted to test it.</description>
		<content:encoded><![CDATA[<p>That is really strange! If you want to get crazy, this works :)</p>
<p>[cfloop condition="count LT #IIF( true, DE( config.MAX_IMAGES_PER_IMPORT / 8 ), DE(0) )#"]</p>
<p>No need to, but I just wanted to test it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/comment-page-1/#comment-586</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Tue, 28 Nov 2006 04:29:41 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/#comment-586</guid>
		<description>Tony,

Why is it obvious that that should cause a syntax error?  I consider myself pretty knowledgable about the CF language and it definitely seems at odds with every other piece of syntax I&#039;ve come across.  Perhaps a better question would be this one.

If this is legal:

[cfparam name=&quot;x&quot; default=&quot;count LT #config.MAX_IMAGES_PER_IMPORT / 8#&quot; /&gt;

why isn&#039;t this?

[cfloop condition=&quot;count LT #config.MAX_IMAGES_PER_IMPORT / 8#&quot; /&gt;

Obviously the two have different runtime semantics, but a syntax error can&#039;t be caused by those.</description>
		<content:encoded><![CDATA[<p>Tony,</p>
<p>Why is it obvious that that should cause a syntax error?  I consider myself pretty knowledgable about the CF language and it definitely seems at odds with every other piece of syntax I've come across.  Perhaps a better question would be this one.</p>
<p>If this is legal:</p>
<p>[cfparam name="x" default="count LT #config.MAX_IMAGES_PER_IMPORT / 8#" /></p>
<p>why isn't this?</p>
<p>[cfloop condition="count LT #config.MAX_IMAGES_PER_IMPORT / 8#" /></p>
<p>Obviously the two have different runtime semantics, but a syntax error can't be caused by those.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/comment-page-1/#comment-585</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Tue, 28 Nov 2006 04:20:24 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/#comment-585</guid>
		<description>Patrick,

You&#039;re right on both counts.  The hashes are almost totally irrelevant, as the expression will be evaluated no later than &quot;each iteration&quot;.  In this simple case, the cost of evaluating the full expression is quite low (division is an expensive arithmetic op, but pales next to a CFC method call).  However, if you have a time-consuming expression (like a method call that queries the DB, or worse yet, the filesystem) you could see a nice advantage by using the hashes and only doing the evaluation once, if that suits the need.

Dropping the hashes is exactly what I did, I was more remarking that it&#039;s weird that the attribute value behaves unlike every other attribute value I can think of.</description>
		<content:encoded><![CDATA[<p>Patrick,</p>
<p>You're right on both counts.  The hashes are almost totally irrelevant, as the expression will be evaluated no later than "each iteration".  In this simple case, the cost of evaluating the full expression is quite low (division is an expensive arithmetic op, but pales next to a CFC method call).  However, if you have a time-consuming expression (like a method call that queries the DB, or worse yet, the filesystem) you could see a nice advantage by using the hashes and only doing the evaluation once, if that suits the need.</p>
<p>Dropping the hashes is exactly what I did, I was more remarking that it's weird that the attribute value behaves unlike every other attribute value I can think of.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Petruzzi</title>
		<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/comment-page-1/#comment-584</link>
		<dc:creator>Tony Petruzzi</dc:creator>
		<pubDate>Tue, 28 Nov 2006 02:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/#comment-584</guid>
		<description>I don&#039;t see the big surprise here.

count LT #config.MAX_IMAGES_PER_IMPORT / 8#

That would obviously throw a syntax error. This isn&#039;t a cfloop weirdness, it&#039;s a syntax error on your part. Sorry for coming off as sounding like a jerk but before you say something is weird or a bug, you should make sure that it is.</description>
		<content:encoded><![CDATA[<p>I don't see the big surprise here.</p>
<p>count LT #config.MAX_IMAGES_PER_IMPORT / 8#</p>
<p>That would obviously throw a syntax error. This isn't a cfloop weirdness, it's a syntax error on your part. Sorry for coming off as sounding like a jerk but before you say something is weird or a bug, you should make sure that it is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick McElhaney</title>
		<link>https://www.barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/comment-page-1/#comment-583</link>
		<dc:creator>Patrick McElhaney</dc:creator>
		<pubDate>Tue, 28 Nov 2006 02:49:57 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/2006/11/27/weird-cfloop-quirk/#comment-583</guid>
		<description>For a while you couldn&#039;t use operators within hashes in CF. I think it worked originally, then it didn&#039;t work for a couple of versions, and then it worked again. 

Actually, I don&#039;t think you even need the hashes in this case. :)

Patrick</description>
		<content:encoded><![CDATA[<p>For a while you couldn't use operators within hashes in CF. I think it worked originally, then it didn't work for a couple of versions, and then it worked again. </p>
<p>Actually, I don't think you even need the hashes in this case. :)</p>
<p>Patrick</p>
]]></content:encoded>
	</item>
</channel>
</rss>
