Bug 6484 – compose can't take multi arg functions

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2011-08-12T13:17:24Z
Last change time
2020-10-29T02:34:52Z
Keywords
pull
Assigned to
No Owner
Creator
Ellery Newcomer

Comments

Comment #0 by ellery-newcomer — 2011-08-12T13:17:24Z
unless only passed one function. Of course, this doesn't make sense for any but the innermost function, e.g. int f(int){..} int g(int){..} int h(int,int,int){...} alias compose!(f,g,h) F; assert(F(x,y,z) == f(g(h(x,y,z)))); This functionality can be trivially added by changing in composeImpl doIt(E)(E a) to doIt(E...)(E a) If conserving param modifiers is desired, it would likely take a good deal more work.
Comment #1 by github-bugzilla — 2012-08-27T01:34:27Z
Comment #2 by andrej.mitrovich — 2013-02-05T13:19:21Z
(In reply to comment #1) > Commit pushed to master at https://github.com/D-Programming-Language/phobos > > https://github.com/D-Programming-Language/phobos/commit/aa40b3b47d64dbf55bd559f113148925ced61ccf > Merge pull request #753 from mylodon/enh6484 > > fix issue 6484 Note: this pull is unrelated to this bug.
Comment #3 by justin — 2014-06-06T18:40:32Z
Kenji's made some recent changes to compose and I cannot reproduce in 2.065. int f(int a){ return a; } int g(int a){ return a; } int h(int a,int b,int c){ return a * b * c; } import std.functional; alias compose!(f,g,h) F; static assert(F(1,2,3) == f(g(h(1,2,3))));
Comment #4 by snarwin+bugzilla — 2020-10-28T16:20:43Z
This bug still exists in 2.094.0. The example in comment 3 fails to compile, with the following output: --- bug.d(7): Error: template `std.functional.compose!(f, compose).compose` cannot deduce function from argument types `!()(int, int, int)`, candidates are: /usr/include/dmd/phobos/std/functional.d(1161): `compose(E)(E a)` bug.d(7): while evaluating: `static assert(compose(E)(E a)(1, 2, 3) == f(g(h(1, 2, 3))))` ---
Comment #5 by dlang-bot — 2020-10-29T01:55:14Z
@pbackus created dlang/phobos pull request #7685 "Fix issue 6484 - compose can't take multi arg functions" fixing this issue: - Fix issue 6484 - compose can't take multi arg functions https://github.com/dlang/phobos/pull/7685
Comment #6 by dlang-bot — 2020-10-29T02:34:52Z
dlang/phobos pull request #7685 "Fix issue 6484 - compose can't take multi arg functions" was merged into master: - 4083852b4b3637595d1a35eb85fc97b7dcc6ced0 by Paul Backus: Fix issue 6484 - compose can't take multi arg functions https://github.com/dlang/phobos/pull/7685