Another warning about CFCs

Tom Muck wrote a good blog entry today talking about weirdness he say when he did a structCopy() operation on a CFC. To me, this was obviously a misunderstanding. CFCs aren't structs. But, like I mentioned in my post a few days ago, it can be confusing. My earlier entry mentioned how duplicate used to work on CFCs, but it returned something that wasn't really a CFC. It seems like structCopy has the same issues. You can see this clearly if you dump a CFC and compare it to the dump of a structCopied CFC.

So - remember - you can't duplicate or structCopy a CFC. Duplicate will throw an error in recent versions. StructCopy, unfortunately, will not. I'm going to file a bug report on this now.

Archived Comments

Comment 1 by Matt Williams posted on 3/13/2006 at 6:32 PM

How about StructAppend? I just read Hal Helm's CFDJ article on Mixins and he used StructAppend to add methods from one CFC to another.

Your thoughts?

Comment 2 by Justice posted on 3/13/2006 at 7:41 PM

Matt,

Just curious, why would you need to structAppend, compared to simply extending an existing .cfc?

Comment 3 by Raymond Camden posted on 3/15/2006 at 9:12 PM

If it works, it's a bug. Unless it creates a ref.