4 ms·
I guess it's more about writing less & better than using known functions -- in the same reasoning, I /could/ use new/delete in C++, but I always end up using un
by Snaipe 12y ago
I guess it's more about writing less & better than using known functions -- in the same reasoning, I /could/ use new/delete in C++, but I always end up using unique_ptr<T>(...) because it's just better, and we usually don't really know/care about the implementation details.
Now I realize that the comparison I made isn't fair since unique_ptr<T> is standard C++ (and hence, polished), and mine isn't and will never be standard C, but abstraction here is not that much of a threat to understanding -- in the end, it's still syntactic sugar on top of smalloc/sfree.
As a last word, I'll say that this is mostly a toy project,
and I probably won't have the occasion to fully use it. This is just a proof of concept to say that it is possible to have modern idioms in C.
- cpeterso 12y agoIt would be nice if C++ added syntactic sugar sigils for unique_ptr<T> and shared_ptr<T> like Rust used to.