By ref. Darryl Lyons
[EMAIL PROTECTED] wrote on 01/06/2005 11:23:01 AM: > Question then: > > How do structs get passed in arguments in CF7 - by reference or by value? > > (I haven't got a cf7 box at hand) > > In 6.x, I'm pretty sure it's by reference. > > Mark > > On 6/1/05, Sean Corfield <[EMAIL PROTECTED]> wrote: > > On 5/31/05, Darryl Lyons <[EMAIL PROTECTED]> wrote: > > > Aren't arrays passed by value into methods? > > > > Yes, so I was a little surprised to see Gareth's claim that he got two > > elements back in CF6. So I tried it on CF6.1 and 6.1.1 and, yes, he's > > right. Weird. But I definitely would have expected it to pass the > > array by value. > > > > I did a bit more digging. If you assign an array it does it by value > > not by reference: > > > > <cfset a1 = arrayNew(1)> > > <cfset a1[1] = "Hello"> > > <cfset a2 = a1> > > <cfset a2[2] = "World"> > > > > Dump both of those and you'll find a1 still has just "Hello" but a2 > > has both. Similarly, if you now change a1[1] to "Goodbye" you'll see > > that a2 is unaffected. > > > > True in CF6.1 and 6.1.1 and 7.0. > > > > Now look at return values. If you return an array, it returns by > > value. I'm not going to show the test code here but I tested it and > > confirmed that it is by value (have a method return > > variables.someArray, modify it in the calling code and then call back > > into the CFC - variables.someArray is unmodified. Similarly, return > > variables.someArray and then call a method that modifies it inside the > > CFC - outside the CFC the previously returned array is unchanged). > > > > Now, CF7 treats array arguments as pass by value - in line with > > assignments and returns. > > > > CF6.1 / CF6.1.1 treats array assignment and return as by value but > > passes arguments by reference. > > > > I can only deduce from this that it was considered a bug in CF6.1 that > > got fixed in CF7 so that arrays were treated consistently. > > -- > > Sean A Corfield -- http://corfield.org/ > > Team Fusebox -- http://fusebox.org/ > > Got Gmail? -- I have 50, yes 50, invites to give away! > > > > -- > E: [EMAIL PROTECTED] > W: www.compoundtheory.com > ICQ: 3094740 > > --- > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > To unsubscribe send a blank email to [EMAIL PROTECTED] > Aussie Macromedia Developers: http://lists.daemon.com.au/ To unsubscribe from this email please forward this email to [EMAIL PROTECTED] This email message is confidential and may be privileged. Unauthorised use, copying or distribution of any part of this email including attachments is prohibited. If you are not the intended recipient please forward the email to [EMAIL PROTECTED] and delete the original. ABN AMRO Morgans Limited and its associates hold or may hold securities in the companies/trusts mentioned herein. Any general advice included in this email has been prepared without taking into account your objectives, financial situation or needs. Before acting on the advice, you should consider its appropriateness or discuss with one of our investment advisors. To the extent permitted by law we exclude (and where the law does not permit an exclusion, limit to the extent permitted by law) all liability for any direct, indirect and consequential costs, losses, damages and expenses incurred in any way (including but not limited to that arising from negligence), connected with any use or access to this email or any reliance on information contained in this email or any attachments. ABN AMRO Morgans Limited (ABN 49 010 669 726 AFSL 235410) A Participant of ASX Group A Principal Member of the Financial Planning Association --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
