tracker issue : CF-4198396

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

Support "arrow functions" syntax for closures

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood ()

Created: 03/10/2017

Components: Language, Closures

Versions: 2016,11.0,10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: / CF2018U5

Priority/Frequency: Normal /

Locale/System: /

Vote Count: 16

Please support the popular "arrow function" syntax for declaring closures.  Please copy the precedent already set by Lucee Server.  This is documented here:

It basically works like this:

Simple lambda with no arguments

// Using a traditional function
makeSix = function() { return 5 + 1; }

// Using a lambda expression
makeSix = () => 5 + 1;

Simple lambda with arguments:

// Takes two numeric values and adds them
add = (numeric x, numeric y) => x + y;

Another example with an argument:

// Takes a numeric value and returns a string
isOdd = (numeric n) => {
  if ( n % 2 == 0 ) {
    return 'even';
  } else {
    return 'odd';



Please note, arrow functions are mentioned in this ticket, but it's a more general ticket with several enhancements so I entered this specific ticket for it.
Comment by Bradley W.
1112 | March 10, 2017 07:29:58 PM GMT
This would be amazing and modern. I remain skeptical however that Adobe would ever do such a thing. Voting because I am persistently hopeful Adobe will become cool again.
Comment by Jim P.
1113 | March 10, 2017 08:44:16 PM GMT
+1 - But I'd like to see struct/array literal fixed properly first. And the only way to fix -that- is a complete rewrite of it.
Vote by Aaron N.
1116 | March 10, 2017 09:38:27 PM GMT
Regarding my vote comment that mentioned struct/array literal needing fixed, Adobe said "fixing this would need almost a re-write for implicit struct/array implementation" in ticket Thanks!, -Aaron
Comment by Aaron N.
1114 | March 10, 2017 09:49:20 PM GMT
Is this something done for 2018?
Comment by Luis M.
1115 | November 27, 2017 07:14:20 PM GMT
This is marked as "fixed" but the examples given in the ticket throw syntax errors in 2018 beta 3. Is this part of Aether?
Comment by Bradley W.
29275 | July 11, 2018 04:38:20 AM GMT
Hello? The first example in this post doesn't work on the final release of 2018 yet this ticket is marked as fixed. What is up?
Comment by Bradley W.
29381 | July 24, 2018 05:16:11 AM GMT
Brad : This has been fixed recently on 28th June and is in testing phase as of now. This is not a part of Aether.
Comment by Ashudeep S.
29382 | July 24, 2018 05:59:15 AM GMT
Client Communication 101, Ashudeep: When the status of a ticket changes, always (*always*) add a comment explaining the change: what was done, why, what the client can expect next. This applies to you, and also applies to everyone else who touches issues in the bug tracker. Dealing with these CF issues should not be a big mystery for your clients. Keep them abreast of the situation! So when's this fix going to be released? It's not really "fixed" until it's out the door.
Comment by Adam C.
29387 | July 24, 2018 08:18:38 AM GMT
Hi Adam , We support the following syntax as of now , {code:java} <cfscript> isOdd = (numeric n) => { if ( n % 2 == 0 ) { return 'even'; } else { return 'odd'; } }; writeOutput(isOdd(1)); writeOutput(isOdd(10)); </cfscript> {code}   {code:java} <cfscript> add = (numeric x, numeric y,numeric z) => 5+6-23; writeOutput(add(3,4,2)); </cfscript> {code}   {code:java} <cfscript> add = (numeric x, numeric y,numeric z) => x * y -z; writeOutput(add(3,4,2)); </cfscript> {code} We are still in the testing phase , and looking for other lambda syntaxes that we can support. This fix would be available in the next update of ColdFusion 2018. Thanks, Suchika
Comment by Suchika S.
29388 | July 24, 2018 08:36:23 AM GMT
Thanks Suchika: that's a great answer.
Comment by Adam C.
29389 | July 24, 2018 08:52:55 AM GMT
Thank you for the update. That information was definitely not clear from the ticket. I look forward to testing the changes. Also, I know you guys looked at Lucee a bit in the 2018 cycle to compare features which was great. Keep an eye on some of the Lucee bugs for arrow functions which document a few things still not quite right over there (lest you copy what they did even if it was wrong!) That way we can try and keep both CF engines on the same page. Ex: Thx again, I'm really excited to finally be able to use this syntax in my BDD tests across engines!
Comment by Bradley W.
29394 | July 24, 2018 04:59:10 PM GMT
As per my discussion with Awdhesh and based on Suchika's comment at 24/Jul/18 14:06, the fix will be available in the upcoming update, i.e. CF2018 U2. If we hit any blocker, then, please leave an external note.  
Comment by Anit K.
29701 | September 14, 2018 11:10:52 AM GMT
The most recent comment on this ticket indicates that this feature would be part of Update 2, but it isn't mentioned in the patch notes for Update 2 nor 3. Can somebody confirm whether this feature is available yet?
Comment by Justin L.
30598 | April 02, 2019 12:56:36 PM GMT
Can we get an update on this ticket? It's been marked fixed since before 2018 released and we're still waiting for the feature.
Comment by Bradley W.
30601 | April 03, 2019 06:36:44 PM GMT
Brad : Will be shipped as part of Sep update ! 
Comment by Suresh J.
31352 | September 20, 2019 04:58:03 AM GMT
@suresh, is there a way I can help test it before it's released? I'd like to confirm it's done right and that you didn't make some of the same mistakes that Lucee made.
Comment by Bradley W.
31354 | September 20, 2019 02:33:43 PM GMT