Open xareelee opened 5 years ago
Yes partial application would be a significant improvement!
Named parameters need to be handled as well. I need to be able to fix some named parameters and obtain a new function of the remaining parameters. To accomplish this now, I must write a lot of boilerplate defining functions that capture parameter values and return other functions of fewer parameters. It is a lot of boilerplate!!
(I'm interested in partial application. I'm not interested in currying. See Currying vs Partial Application)
What about:
request(query) // return a Future<ResponseData>
.then(=> processData(it, options)) // pass data to processData(data, options)
.then(=> writeDataIntoDatabase(database, it)); // pass data to writeDataIntoDatabase(database, data)
?
probably isn't a good choice since it is used for so many other things, especially once NNBD lands: conditional operator, nullable type, null-aware method calls, null-aware operator, etc.
See also: #8.
Would this be more feasible if we have a perfect correspondence between tuples and argument lists? (#1293)
I do like partial application and, yes, tuples might help somewhat, but I don't think even tuples as arguments list will give us partial application for free. It would still be a separate feature we'd have to think through.
It's just a suggestion for Dart lang, not a bug report. I did not find a way to publish my suggestion, so I file this here.
Partial application would be useful for functional programming.
With question mark
?
when calling a function, it turns a function into 'currying' similar to a proposal in tc39. For example,This feature would be useful to make functions ease-of-use in functional programming with Future/Promise and Stream/Rx, because the design of the function parameter ordering is irrelative.