Visit the ColdFusionProNews Directory
Beginners
Installation, Coding Techniques, Data Structures...
CF Powered Sites
Stores, Directories, Universities...
Developers
Developers, Designers, Experts...
E-commerce
Shoes, Food, Music...
Education
Books, Online Resource, Languages...
Expert
LiveChat , CFX XMLParser , User Defined Function Library...
Hosting
Dedicated Servers, Virtual Server, Multi-user...
Intermediate
AutoResize , DataSource Encryption, Guestbook...

Submit your site for FREE

Archive for July, 2008

Why You Might Use StructCopy() Instead of Duplicate()

Wednesday, July 16th, 2008

Over on Will Tomlinson’s blog there’s a piece about using structCopy() to create a copy of a struct and a note from Charlie Griefer cautioning that for Will’s example, he probably needed to use duplicate() instead. After discussing this will Will on IM, I figured it might be instructive to look at how structCopy() differs from duplicate() and why you might use it instead.

First off, let me say that the reason I think this causes confusion for a lot of CFers is that they don’t have a Computer Science background so they’ve not had the “Memory and Pointers 101″ course that makes this stuff a lot clearer. Hopefully, this blog post will help fill in some of the gaps.

Some basics. When you assign something to a variable in CFML, you are really doing two things: you are creating a label (the variable name) and you are allocating some memory to associate the label with the data. In particular, with structs, the struct itself exists in a block of memory (well, lots of connected blocks of memory) and then the variable “points to” the struct data.

(more…)


















Get Your Site
Submitted for Free
in the World's Largest
B2B Directory!

Email Address:
*URL:
*
*Indicates Mandatory Field
Terms & Conditions