CFLOOP Rant.

Posted by Mark Drew on code on August 4, 2011

Tagged under railo,coldfusion

<rant>

I have to get this off my chest: the tag cfloop *REALLY* annoys me.

Not in all it's manifestations mind you, just in one of them, and that is... cfloop array. Why you might ask?
Well, if you want to loop an array you can do:

</cfloop> </code>

What "a" is in the index, is the actual item in the array. I think this is totally wrong to the point that if I had hair I would pull it out.
When the array attribute was introduced, I really think the developers had a brain fart.
They could have so easily used another attribute, maybe one that is already there. The attribute of "item" for example! I mean, it was there loitering in the tag lib, being used for collections, such as:

</cfloop> </code>

Now THAT makes sense! But why all the whining you might ask? Well, let's consider if you want to actually get the index of the array, what do you have to do? Oh yeah... set up another damn variable:

<cfset counter++> </cfloop> </code>

Wouldn't it have made a LOT more sense to do the following?:

The actual item The index of the item </cfloop> </code>

See? now "a" can be the *ITEM* in the array and "counter" can be the *index* of the array.

</rant>

Side rant: Why name it "collection" when we could have named it "struct"?




comments powered by Disqus