tracker issue : CF-3941525

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

Interface restrictions too rigid regarding optional arguments

| View in Tracker

Status/Resolution/Reason: To Fix//Investigate

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

Created: 02/17/2015

Components: Language

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Normal / Few users will encounter

Locale/System: English / Platforms All

Vote Count: 1

See: http://blog.adamcameron.me/2013/07/question-for-yall-re-coldfusion.html

Given this interface:

~~~~
// IAdditionalOptional.cfc
interface {
	public numeric function f(required numeric x);
}
~~~~

This CFC's f() method *does* fulfil the contract:

~~~~
// AdditionalOptional.cfc
component implements="IAdditionalOptional" {

	public numeric function f(required numeric x, numeric y){
		if (structKeyExists(arguments, "y")){
			return x * y;
		}else{
			return x * 2;
		}
	}

}
~~~~

The requirement is that f() is defined and will take a numeric argument x. Which it does. Job done. Note that the y argument is *optional* so f(x[,y]) can indeed be used in any situation where f(x) is the requirements.

You're being too literal in what interface contracts are for, and overlooking that CFML has optional arguments.

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

Watson Bug ID:	3941525

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

Attachments:

Comments:

Also see https://bitbucket.org/lucee/lucee/issue/171/interface-restrictions-too-rigid-regarding
Comment by External U.
8385 | February 17, 2015 07:33:14 PM GMT
How are those investigations going?
Comment by External U.
8386 | September 29, 2015 07:23:31 AM GMT
+1 ......................
Vote by External U.
8388 | September 30, 2015 03:02:57 AM GMT
Hello?
Comment by External U.
8387 | January 25, 2016 08:21:01 AM GMT