manuelbarzi (2018-10-25T10:59:07.000Z)
manuelbarzi at gmail.com (2018-10-25T11:28:42.035Z)
taking this old discussion back a bit ( https://esdiscuss.org/topic/arrow-function-syntax-simplified), why shouldn't be a good idea to deprecate the use of `function` in pro of thin-arrow `->`, being applicable in same cases (including named function)? just a bit of code with more about proposals: ``` const GLOBAL_FACTOR = 2 const result = [1, 2, 3].map(function(value) { return GLOBAL_FACTOR * value }) // PROPOSAL 1 - normal anonymous function (same as fat-arrow, but dynamic binding, nothing much new here as from previous proposals): // const result = [1, 2, 3].map(value -> GLOBAL_FACTOR * value) function applyFactor(value) { return GLOBAL_FACTOR * value } // PROPOSAL 2 - named function declaration (without 'function' keyword): // applyFactor(value) -> GLOBAL_FACTOR * value // referenced function (following PROPOSAL 1): // const applyFactor = value -> GLOBAL_FACTOR * value const sameResult = [1, 2, 3].map(applyFactor) ``` justification i read against this proposal is mainly that thin-arrow may bring "more confusion" and may "provide poor or no benefit" co-existing with fat-arrow. but having both may bring devs the chance to understand the differences in the learning process as any other feature. the only "big deal" would be to be aware of fix vs dynamic binding, which is something a dev must understand sooner or later, independently of syntax (it can be just explained with traditional function() {} and .bind() method). on the other hand it would bring the chance to avoid over-using fat-arrow when binding it's not really necessary (which may "save" internal binding processing too), still keeping a simpler and shorter syntax as fat-arrows, avoiding the requirement of the keyword `function`.
manuelbarzi at gmail.com (2018-10-25T11:20:16.299Z)
taking this old discussion back a bit ( https://esdiscuss.org/topic/arrow-function-syntax-simplified), why shouldn't be a good idea to deprecate the use of "function" in pro of thin-arrow "->", being applicable in same cases (including named function)? just a bit of code with more about proposals: ``` const GLOBAL_FACTOR = 2 const result = [1, 2, 3].map(function(value) { return GLOBAL_FACTOR * value }) // PROPOSAL 1 - normal anonymous function (same as fat-arrow, but dynamic binding, nothing much new here as from previous proposals): // const result = [1, 2, 3].map(value -> GLOBAL_FACTOR * value) function applyFactor(value) { return GLOBAL_FACTOR * value } // PROPOSAL 2 - named function declaration (without 'function' keyword): // applyFactor(value) -> GLOBAL_FACTOR * value // referenced function (following PROPOSAL 1): // const applyFactor = value -> GLOBAL_FACTOR * value const sameResult = [1, 2, 3].map(applyFactor) ``` justification i read against this proposal is mainly that thin-arrow may bring "more confusion" and may "provide poor or no benefit" co-existing with fat-arrow. but having both may bring devs the chance to understand the differences in the learning process as any other feature. the only "big deal" would be to be aware of fix vs dynamic binding, which is something a dev must understand sooner or later, independently of syntax (it can be just explained with traditional function() {} and .bind() method). on the other hand it would bring the chance to avoid over-using fat-arrow when binding it's not really necessary (which may "save" internal binding processing too). finally, a simpler and shorter syntax avoiding the requirement of the keyword 'function'.