-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Boxed closures should be nameable, too #2257
Comments
The annoying part is getting the scoping right. It seems so special case to introduce named fn@'s that can only recurse to themselves. On the other hand, introducing a |
Right. I mean, one solution is to have named
But
This is very painful, in part because an enum is needed (to get around the 'no recursive non-enumful types' issue), and in part because it's an extra step. (The enum is very painful, since it needs the 'alt' mess to get at the contents.) This could be trivially rewritten with something of the form:
I mentioned this on IRC. @nikomatsakis noted that there are two issues here -- type-checking this (in particular, I think you now need to seriously think hard about how to infer the type of 'rq', if you wish to do so), and guaranteeing that intermediate states are not visible. Even if this is constrained to boxes, it's still possible for intermediate states to exist -- how do the MLs deal with this? |
Talked to @msullivan today. Apparently the way the MLs do it is by saying that only lambdas are allowed to be |
What about:
Edit: Oh wait, the closures copy. I guess you would need:
Blech. |
Closing due to lack of consensus. Reopen if someone is still interested. |
Add `./miri fmt` and check in CI
…check2-v2 Bump mdbook-linkcheck2 dependency version
It would be really nice if it were possible for a boxed closure to recur on itself. A use case that I find particularly compelling is a variable substitution, which currently looks like this (
impl
version suggested by @nikomatsakis):Previously, it was even worse; the inner function was something of the form 'fn subst_(...)', which passed 'gen', 'x', 'y', and 'fvs' all the way through, which was really painful.
@nikomatsakis then suggested that I file this bug. My suggestion is syntax of the form:
fn@ subst_(...)
. The problem then is if we want functions that mutually recur; another thought, then, is an ML-stylelet rec func1 = fn@(...) {...} and func2 = fn@(...){...}
.Thoughts?
The text was updated successfully, but these errors were encountered: