tracker issue : CF-3644083

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

Rasing bug#3495357 again because you didn't look into the problem before closing it.

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Andrew Scott / Andrew Scott (Andrew Scott)

Created: 10/01/2013

Components: Documentation

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Server

Vote Count: 1

Problem Description:

In trying to give you examples of the problem that bug #3495357 raises, I discovered that your own documentation is hindering this feature. There is no structure on how to learn this, by that I mean the documentation is all over the place and people have to bend over backwards searching for hidden information.

If you want to provide documentation like this.

Finding anything like this for ColdFusion, is what really kills this language. Anyway back to the previous bug.

That code become a result of this in your documentation, which clearly indicates that what I was asking for was indeed on the cards at one stage and pulled out of the code.

Because not only does this code in your documentation not work, but it gives people a false sense of how it all is supposed to work. I have searched high and low on materials, blogs and anything I can find that would explain how Closures actually work and can be used in ColdFusion.

	function exampleClosure(arg1)
	    function exampleReturned(innerArg)
	        return innerArg + owner.arg1;
	    return a reference to the inner function defined.
		return exampleReturned;

Guess what, nobody really knows 100% how it works, especially when your documentation shows the above. And then in comparison to the other bug #3495357, it goes well how does this actually work then.

For example lets take this code.

	function helloTranslator(String helloWorld) {
		return function(String name) {
			return "#helloWorld#, #name#";
	var test = helloTranslator("Andy");

Will error saying that the variable name is undefined, yet it is valid, extremely valid ColdFusion code. So if we then take the initiative to refactor it to what we think it should be.

	function helloTranslator(String helloWorld) {
		return function(String name) {
			return "#helloWorld#,";
	var test = helloTranslator("Andy");

Then presents an error that the variable name doesn't exist in arguments.

So either this is bugged or your documents are wrong!

Steps to Reproduce:

Actual Result:

Expected Result:

Any Workarounds:

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

Watson Bug ID:	3644083

Deployment Phase:	Release Candidate

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



Yeah, those docs are a) wrong; b) incomprehensible anyhow. It's as if the person who wrote them doesn't really understand what they're documenting. And definitely doesn't test their code. Poor form. -- Adam
Vote by External U.
14382 | October 02, 2013 03:27:04 PM GMT
Another thing to note, now I am not sure this is a grails thing or its how closures should work. But in the grails docs while explaining how closures works it shows something like this def localMethod() { def localVariable = new java.util.Date() return { println localVariable } } def clos = localMethod() println "Executing the Closure:" clos() now closures by default have one argument always, however when we try to do something like the return statement above it errors. So the closest to the above code in CFML I can come up with is function localMethod() { var localVariable = new java.util.Date() var localVariable = createObject("java", "java.util.Date").init(); return { writeoutput(localVariable"); } } clos = localMethod() writeOutput( "Executing the Closure:" ); clos(); Which throws an error... It is like the return statement, can't accept closures on it. As defining a function here also errors.
Comment by External U.
14367 | October 03, 2013 12:28:11 AM GMT
So when we go to the documentation to see what is possible, how it is supposed to work.. There is nothing in the documentation except badly written code that suggests something should work and yet it doesn't. Closures, needs a lot more information in the documentation than it has.
Comment by External U.
14368 | October 03, 2013 12:30:19 AM GMT
I would recommend you to better read the documentation and understand what Closure is and how they should be used instead. Have you run the Closure examples given in the doc before you say that they dont run? If there is some example which does not run, please share those snippets with us or point it in the documentation so that they can get fixed. Looking at the code snippets, it is evident that the code written is not correct and please note that they are not the same as the ones given in the documentation. They are your modifications. The function returned from helloTranslator expects an argument which is not passed when that function is called. You would need to make the following change var test = helloTranslator("Greetings"); writeDump(test("Andy")); Closing the bug once again.
Comment by Rupesh K.
14369 | October 08, 2013 08:44:43 AM GMT
Rupesh, the code at the very top was copied from the ColdFusion 10 online documentation. Which can be found here.... There is more to this than meets the eye Rupesh. More unexpected behavior And yes I did as you put it, better read the documentation. It is you who has no clue what is in the documentation. Seriously Adobe.....
Comment by External U.
14370 | October 08, 2013 08:50:53 AM GMT
Another example of Adobe closing a bug, without understanding the issue at hand.
Comment by External U.
14371 | October 08, 2013 08:52:00 AM GMT
If nothing else, Rupesh, you have a docs bug here. So there is still a bug to deal with. I do think, though, that is this perhaps the core of the problem. Seriously: just leave the CLOSE button alone until you understand the issue. Another problem here is you are WAY too fast to press the close button. What you SHOULD be doing is liasing with Andrew and making sure you're both on the same page before deciding whether there's work do to on a given ticket. -- Adam
Comment by External U.
14372 | October 08, 2013 09:05:47 AM GMT
Could you please share the documentation link that you are referring to which has the wrong example. May be we are looking at two different things. Here is the doc page I am referring to Here is the code in the doc example : ------------------- <cfscript> function helloTranslator(String helloWord) { return function(String name) { return "#helloWord#, #name#"; }; } helloInHindi=helloTranslator("Namaste"); helloInFrench=helloTranslator("Bonjour"); writeoutput(helloInHindi("Anna")); ------------- Compare that with the example you have and I hope you would see the difference. You sure did copy the Closure definition but the mistake happened while calling it. When you call 'helloTranslator' function, it returns a function that needs an argument 'name'. In your example, you are not passing any argument while calling 'test' and that is why it complains that the variable 'name' is undefined. please help me understand how throwing the error - 'name' is undefined OR 'name' doesn't exist in argument is a bug. As I said earlier, this code ----------- var test = helloTranslator("Andy"); writeDump(test()); ----------- needs to be modified as ---------- var test = helloTranslator("Andy"); writeDump(test('scott')); --------- Am I missing something?
Comment by Rupesh K.
14373 | October 08, 2013 11:54:08 AM GMT
You're not even looking at the current documentation site, Rupesh. Andy's first example is this one: His second example is incorrect, as you state. -- Adam
Comment by External U.
14374 | October 08, 2013 12:33:46 PM GMT
Thanks Adam for pointing us to that. You are true soulmate to Andrew! It is only you who could have figured that in this long bug description and the two examples which was clearly user error, there was a doc bug lying. I am not sure how 'owner' came to the docs as it was never implemented. We will get the doc fixed. Note to Doc - we need to remove 'owner' from the CF 10 documentation.
Comment by Rupesh K.
14375 | October 08, 2013 12:48:25 PM GMT
;-) Cheers Rupesh. I have to admit I didn't spot Andrew's error initially either, I just knew the docs on that page had some issues, so presumed he was talking solely about those. -- Adam
Comment by External U.
14376 | October 08, 2013 12:59:38 PM GMT
Rupesh, how do you clearly define user error? I have seen you close bugs marked user error, and we as a developer are like how the hell is that user error? Closures have no scope that is accessible by the developer, yet internally there is some form of scope going on. Closures are defined to be able to use external or outer scopes as well as inner scopes. Your own documentation indicates that there was at some stage going to be an outer scope. Closures have a difficult time getting anything right at all, my first posting was to ask why is there no such scope? My next posts, where to then highlight the other potential dangerous things that are going on with more examples of how broken NOT having a scope can be. It is also not user error, when things are inside their scopes and they can't be accessed in that manner? Rupesh in all the years you have been on this team, you have personally closed more bugs without more information than any other CF team member. Just because you took the ticet the wrong way does not give you the right to close tickets because YOU believe it is user error. Not everyone understands the inner workins of code they can not see, just because your code indictaes user error, does not mean it is user error. All you need to do Rupesh, is actually ask more questions instead of closing tickets.
Comment by External U.
14377 | October 09, 2013 07:48:00 PM GMT
Take this code, that was also marked as user error by the Adobe team. // ColdBox Reload Checks application.cbBootStrap.reloadChecks(); //Process a ColdBox request only if( findNoCase('index.cfm',listLast(arguments.targetPage,"/")) ){ application.cbBootStrap.processColdBoxRequest(); } return true; When run in ColdFusion, this code actually works as it is written and yet inside the line debugger it doesn't work. It actually skips over code that it should not skip over. And yet it was marked as User Error. Really Adobe needs better rapport with their customers, not everyone can explain things correctly. Mostly a little more information is all that is needed. But Rupesh, would rather say user error than anything else.
Comment by External U.
14378 | October 09, 2013 07:50:44 PM GMT
I have already answered you and there is no point in repeating myself. Please read my earlier comment.
Comment by Rupesh K.
14379 | October 10, 2013 04:42:03 AM GMT
Andrew, this code: function helloTranslator(String helloWorld) { return function(String name) { return "#helloWorld#, #name#"; }; } var test = helloTranslator("Andy"); writeDump(test());// <=============== HERE errors because it's got a logic error where indicated. test() *requires* an argument. You're not passing one. That's why it errors. Your code is wrong. Nothing to do with closures, nothing to do with the code in the docs (the code in the docs for this example is correct), it's just *your code is wrong*. The code you posted two comments below this one is nothing to do with this ticket, so, really *WTF*? Can you please *concentrate* and just stick to one issue at a time, and one issue per ticket. Don't use the bug tracker just for a dumping ground for whatever happens to be annoying you at a given moment. Which, I'm afraid, is how you are coming across. And I think you owe Rupesh and apology. -- Adam
Comment by External U.
14380 | October 10, 2013 04:56:20 AM GMT
Ok Adam & Rupesh, yes you are both picking on the fact that I copied the wrong snippet of code. It does not excuse the fact that there are scoping issues. I have given enough examples, to show that there is a scoping issue that really doesn't conform to how closures work. Rupesh, yes I ran you documentation examples. That is how I came across the snippet of code in your documentation that mentions closures. And Rupesh if the documentation was not all over the place, people might actually be able to learn the language with better ease. I provided a grails link on Closures, which not only describes what it is, but it gives many examples of how it can be applied in your code. ColdFusion is like 10 lines of text here, maybe another 10 lines there, but importantly there is little explnation on how what closures actual are. So before coming back at me with DID I do this, well maybe if the docs that Adobe put together it might make our jobs easier. But the docs is not the issue. When I ran into issues with local vars getting trashed, I started to look at how ColdFusion can get this so wrong. So I raised a ticket and you marked it as not worth the effort. Well it has to be worth the effort to actually get the job done right, or at least make it so it works.. for example I should be able to turn this into a closure function(string name) { local.localVar = "Mr " &; return local.localVar; } into function() { local.localVar = "Mrs"; return function(string name) { local.localVar = "Mr " &; return local.localVar; } } Without re-factoring the code so that it avoids the contamination of variables here. And under the way closures work, I should be able to reference local.localVar from within the closure as well as the same variable on the outer. ColdFusion seems to merge these variables into one. So when I go looking for a scope for the closure, we discover there is no such exposed closure. That Rupesh is what we call incorrectly function code or as you would best describe it, a bug in ColdFusion.
Comment by External U.
14381 | October 10, 2013 05:13:49 AM GMT