9 ms·
Well, it doesn't have the runtime to support laziness properly.
by vmchale 7y ago
Well, it doesn't have the runtime to support laziness properly.
- ChrisSD 7y agoSure, it doesn't have much of a runtime at all but Rust does give a firm foundation to build on. Using an `Option` or the `once_cell` library is pretty ergonomic. At worse you use a function call to get a reference to the value instead of using it directly.
- DougBTX 7y agoAgreed, Rust can certainly handle lazy evaluation. All the iterator types for example are lazy, hence the .collect() method which eagerly evaluates a lazy collection. Hiding the fact that a lazy value needs to be mutated to initialise it is a little more work (since a nice API lets the user treat the value as if it doesn’t need to be mutated), but is certainly possible.
- vmchale 7y ago> All the iterator types for example are lazy, It's not proper laziness as defined in Okasaki's thesis/book. One needs more complex things like lazy finger trees.
- paulddraper 7y agoThe iterator is lazy. The language is not.
- fctorial 7y agoWhy would lazy data structures need a runtime? Some kind of GC is necessary for immutable data structures, but wouldn't iterators and generators be enough for implementing laziness?
- vmchale 7y ago> wouldn't iterators and generators be enough for implementing laziness? If you can implement lazy finger trees with iterators I'd love to see it :)