Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

each only accepts lambdas that take a single argument #10352

Open
dlangBugzillaToGithub opened this issue Oct 5, 2018 · 0 comments
Open

each only accepts lambdas that take a single argument #10352

dlangBugzillaToGithub opened this issue Oct 5, 2018 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

iamthewilsonator (@thewilsonator) reported this on 2018-10-05T06:55:35Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=19287

CC List

  • jrdemail2000-dlang

Description

See https://forum.dlang.org/post/tgnnsqkclbcaejhbiprn@forum.dlang.org for the motivation.

struct that contain destructors cannot be closed over (I'm not sure why but thats a different problem) and so 

CantCloseMe o; // some struct with a door
somerange.each!(e => foo(o,e)); //Error: variable `o` has scoped destruction, cannot build closure

fails. But it can't be worked around with 
somerange.each!((e,f) => foo(o,f))(o);

Fails with

Error: template somerange.each!((e,f) => foo(o,f)).each cannot deduce function from argument types !()(SomeRange, CantCloseMe), candidates are:
...

because all of the each functions take only a range or iterable.
@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants