Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)
Created: 09/23/2013
Components: Language
Versions: 10.0
Failure Type: Enhancement Request
Found In Build/Fixed In Build: Final /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Platforms All
Vote Count: 1
See http://cfmlblog.adamcameron.me/2013/09/cfml-suggestion-being-able-to-stipulate.html
Summary:
In ColdFusion (but not in Railo) for some reason, arrays are always duplicated when they are passed as function arguments or tag parameters (incl. custom tag attributes); whereas data of other complex types are passed by reference (for all intents and purposes). Here's some quick code to demonstrate:
[...]
I think ColdFusion is doing the wrong thing here, but I also think it's too late in the day to "fix" it.
What I'd like to be able to do instead is to have some sort of annotation to say "pass this thing as a reference", eg:
function arrayHandler(required &array array){
}
Where &array signifies and array reference, rather than the array itself.
Initially it might seem like this is limited to only arrays, but I also see it as being useful for functions which manipulate & "return" strings as well. Strings are passed by value, and strings can get rather large. So it would be useful to also be able to pass strings by reference too, I think.
Also, being able to force the opposite to occur: for objects that usually pass by reference-copy, being able to pass them by values instead would be handy. Although this is easy enough with duplicate() it'd be more syntactically elegant to be able to do it without the additional function call. This would be icing though.
--
Adam
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3638235
External Customer Info:
External Company:
External Customer Name: Adam Cameron.
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: