tracker issue : CF-4188129

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

BIFs should be usable as arguments expecting functions

| View in Tracker

Status/Resolution/Reason: To Fix//Investigate

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 09/09/2016

Components: Language, Functions

Versions: 2016

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF2016_Update1 /

Priority/Frequency: Trivial / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 4

Repro:

<cfscript>
a = ["tahi", "rua", "toru", "wha"];

toUpperCase = function(s){
	return s.ucase();
};

writeDump(a.map(toUpperCase));

// nope
try {
	writeDump(a.map(ucase));
} catch (any e){
	writeDump([e.message, e.detail]);
}
</cfscript>

Result:

array
1	TAHI
2	RUA
3	TORU
4	WHA
array
1	An exception occurred while calling the function map.
2	Cannot cast coldfusion.runtime.CFPageMethod to coldfusion.runtime.UDFMethod

You guys need to stop making stupid arbitrary distinctions between different types of functions (ref: http://blog.adamcameron.me/2012/12/am-i-right-to-think-this-is-stupid.html)

Anywhere you are making a distinguishment between UDFs, BIFs, functions-declared-by-statement or functions-declare-by-expression needs to be removed from the language. They're all just functions, and all should be usable interchangeably

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

Watson Bug ID:	4188129

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

Attachments:

Comments:

Please take this up in Aether - when you promise to break backward compatibility to clean up stuff. It doesn't matter if there are differences in how this works at the Java level that account for the difference between the behavior of BIFs and UDFs - you need to resolve it so that *all* functions behave as expected *everywhere* in CFML.
Vote by External U.
1845 | September 09, 2016 04:34:07 PM GMT
isClosure is not a function name that should exist at all. isCustomFunction might have some utility - but if something can be called as a function, no matter how it was created, it should be able to be passed to a method expecting or returning a function, no matter how it was created.
Vote by External U.
1846 | September 09, 2016 04:39:21 PM GMT
A function is a function is a function.
Vote by External U.
1847 | September 09, 2016 10:04:00 PM GMT