tracker issue : CF-3540467

select a category, or use search below
(searches all categories and all time range)
Title:

Accept an assignment statement as a parameter for built-in CF functions

| View in Tracker

Status/Resolution/Reason: Closed/Deferred/EnhancementRequired

Reporter/Name(from Bugbase): Henry Ho / Henry Ho (Henry Ho)

Created: 04/11/2013

Components: Language

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 12

"A built-in ColdFusion function cannot accept an assignment statement as a parameter, although it can accept expressions. For example, DIRECTORYLIST(d=a*b) is not acceptable."

e.g. directorylist(path="C:\Users\X\Downloads", recurse=true)>  is much more readable then directorylist("C:\Users\X\Downloads", true)

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3540467

External Customer Info:
External Company:  
External Customer Name: henrylearn2rock
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

+1 This needs to be fixed. Just encountered this. Fix it. Makes no snese to have to write stuff 2 different ways depending if it is a "native" function versus something I write.
Vote by External U.
15722 | November 19, 2013 05:32:19 PM GMT
+1. Indeed. Event SOME native functions will accept name/value pairs (eg: writeDump(), throw()) and not others. This sort of incoherent approach to syntax ought to be ironed out. -- Adam
Vote by External U.
15723 | November 19, 2013 05:38:13 PM GMT
I didn't realize this. I can see how it might not be *required* if all arguments to the function are mandatory, or is no more than 1 optional argument at the end, but the ability to use named parameters should be up to the developer.
Vote by External U.
15724 | November 19, 2013 05:51:34 PM GMT
Fix, please, for the sake of consistency across the language.
Vote by External U.
15725 | November 19, 2013 10:02:18 PM GMT
Should definitely be "fixed". FWIW, this works just fine in Railo (although the argument is absolute_path, not just path) - but Railo allows named arguments for built-in functions...
Vote by External U.
15726 | November 20, 2013 05:49:27 PM GMT
Would be quite useful to be able to pass an argumentCollection struct to built-in functions just like one can with UDFs
Vote by External U.
15727 | November 25, 2013 08:21:01 AM GMT
The inconsistent behaviour and somewhat odd error message (named arguments are called "named arguments" everywhere else, not referred to as "assignment statements") leads to wasted time debugging.
Vote by External U.
15728 | February 28, 2014 12:01:38 AM GMT
Please reopen this & deal with it properly. *Closing* it with "deferred/enhancement required" is not a valid resolution here. If you're going to deal with it in the future, then LEAVE IT OPEN until you deal with it.
Comment by External U.
15720 | December 26, 2014 07:40:18 AM GMT
@jaimemetcher there's nothing wrong with the error message. Built-in ColdFusion functions do not supported named arguments, so what you have there is an assignment expression. The problem is that an assignment expression should be *fine* for a positional argument value. So this code should not result in an error. It should also - *coincidentally* result in the values of the assignment expressions being used as the first two arguments of directoryList(), which happen to be path and recurse. But that would be a coincidence, not by design. I think the ticket is poorly named. It should be more like "allow named arguments for built-in functions" which is, after all, what Henry is actually asking for, it seems.
Comment by External U.
15721 | December 27, 2014 05:50:28 AM GMT
Agree 100% - i would also specifically add that along the same vain argumentCollection would be great to accept as well.
Vote by External U.
15729 | August 17, 2015 04:31:54 AM GMT
+1111111111111111111111111
Vote by External U.
15730 | October 15, 2015 09:21:18 AM GMT
+1 - All built-in functions should allow named arguments
Vote by External U.
15731 | December 05, 2015 01:10:49 AM GMT
Just experienced this in DirectoryList function as mentioned here. Been using cf_directory action="list" all the time
Vote by External U.
15732 | September 07, 2016 02:17:55 AM GMT