Always nice to see Rust slowly converging to C++ levels of complexity.
kibwen•32m ago
What? All of this stuff has been in the language since 2014 at least. If you want stack-allocated closures which can safely close over references, this is the machinery you need. Rust's implementation is the state of the art.
ozgrakkurt•30m ago
Really can’t see how it could be made simpler. Function pointer can’t be a closure because it means something different. You can pass pointers different functions without having multiple versions of the function you are calling. Closures have a unique type and they require you to use generics.
kccqzy•23m ago
But the difference between a closure and a function pointer is essential complexity, not accidental complexity.
If a language were to provide only closures and not function pointers, it would not be low level enough to interface with C code and C ABI. That's definitely not what Rust needs.
fulafel•11m ago
Nah, lots of higher level languages interface with C.
xondono•15m ago
This has been in Rust since before the 1.0 release.
Also, you can’t converge to a diverging number, for Rust to get close to C++’s level of complexity, the C++ WG would have to stop with their garbage.
fulafel•4m ago
Would be interesting to see a comparison with GCC's C closures[1].
meindnoch•36m ago
kibwen•32m ago
ozgrakkurt•30m ago
kccqzy•23m ago
If a language were to provide only closures and not function pointers, it would not be low level enough to interface with C code and C ABI. That's definitely not what Rust needs.
fulafel•11m ago
xondono•15m ago
Also, you can’t converge to a diverging number, for Rust to get close to C++’s level of complexity, the C++ WG would have to stop with their garbage.