4 ms·
The environment contains references/copies/borrows of local variables, depending on a number of conditions on the code. Since the environment struct is generate
by fmap 10y ago
The environment contains references/copies/borrows of local variables, depending on a number of conditions on the code. Since the environment struct is generated by the compiler, this is different from a method call where you specify the struct yourself.
- steveklabnik 10y agoIt's still fundamentally sugar; on nightly, you could write it all yourself.
- fmap 10y agoWhat exactly are you arguing for? Closures can be implemented using closure conversion as a derived form in most languages. That's how you compile the code in the first place... The point is that you reason about closures as ordinary functions with local assumptions. You don't need to know how they are implemented at all. On the other hand, in Rust you need to be aware of the implementation in order to use higher-order functions effectively.
- steveklabnik 10y agoI'm arguing that the statement I quoted in my above comment is incorrect; closures are implemented with functions, not the other way around.