Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by ghoward on Thursday July 15, 2021 @09:33PM
(#27852181)
Yes, those are all problems with destructors, but they are well understood. However, in a language I am currently creating, calling a destructor on a partial object is impossible because the object is created in "one" step. In other words, constructors themselves don't have access to the object in a partially created state.
It does make things much easier.
Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by hnakamur on Thursday July 15, 2021 @08:13PM
(#27851696)
I agree. For example, most of Rust libraries uses the drop handler (something like desctructors) to close a file descriptor.
However it has problems since in async model closing is also async and it may return an error.
So in tokio-uring explicit async close will be provided.
https://github.com/tokio-rs/tokio-uring/pull/1/files#diff-3d...
And you can call close like: file.close().await.unwrap(); https://github.com/tokio-rs/tokio-uring/pull/17/files#diff-b...
It's understandable why a language trying to be close to C in spirit does not have them.