3 ms·
The article itself says: > There’s a generic function in the standard library called `Ada.Unchecked_Deallocation`, which frees memory to the heap. A systems l
by catnaroek 10y ago
The article itself says:
> There’s a generic function in the standard library called `Ada.Unchecked_Deallocation`, which frees memory to the heap.
A systems language without a safe resource finalization story is simply an unsafe language. This isn’t some fringe use case. Finalizing resources is a common operation in systems programming.
Other “benefits” of Ada just consist in bloating the core language with stuff that can be reasonably done in libraries: bounds checking (in ML, this is just a functor that produces an abstract type of bounds-checked integers), concurrency abstractions (as Rust has shown), etc.
- pjmlp 10y agoJust like Rust with unsafe blocks. There are ways in Ada to write programs without ever having to call Unchecked_Deallocation. Good luck having the compiler eliminate bounds checking for library code.
- flyx86 10y agoFor safe resource finalization, Ada provides `Ada.Finalization.Controlled`. This enables you to implement RAII, smart pointers, and other ways of safe finalization. `Ada.Unchecked_Deallocation` is just the bare-metal tool you can implement more intelligent finalization with (because in the end, someone needs to deallocate the memory).
- catnaroek 10y agoWithout substructural types, no matter how much lipstick you put on the pig, use after free will always be possible.