3 ms·
I read that pseudocode and all I think is: this sounds like it's making up for a missing language feature.
by ajkjk 5y ago
I read that pseudocode and all I think is: this sounds like it's making up for a missing language feature.
- valenterry 5y agoWell, it's pseudocode, but it's close enough. Here's a runnable example: https://scastie.scala-lang.org/5klYiw6cT7yckJbn2zGmJg https://scastie.scala-lang.org/5klYiw6cT7yckJbn2zGmJg The gist is: this does everything needed for resources, including preventing errors at compile-time, being composable/reusable and handling errors correctly (you can throw an exception in the middle and the scanners will still be closed). That being said, having it as a language feature might make certain use-cases nicer and more ergonomic. However, it also makes the language much more complex; I don't think resources alone are a sufficient reason to fundamentally change the language. One thing that Rust has gotten fairly right so far is not having added too many special cases and rely on general language features mostly. For example, don't have special syntax/handling for optional/nullable values, but just use the existing macrosystem to deal with it. I hope this philosophy will continue. Rust is here to stay and these kind of decisions make a big difference in the long run.