4 ms·
> Memory safety guarantees that don't go out the window if you ever need to free a dynamic allocation, for starters. Lots of people like to repeat this without
by pyjarrett 5y ago
> Memory safety guarantees that don't go out the window if you ever need to free a dynamic allocation, for starters.
Lots of people like to repeat this without understanding all of the other controls that Ada has for access types (pointers).
Ada access types (like pointers) are typed so you could make multiple equivalents of `Foo` that can't be mixed and matched. e.g. one version of `Foo` might be for one subsystem and another version of `Foo* for a different subsystem, which would prevent you from giving an allocated object from one system to another. You also can't point an access to any arbitrary location without it being specifically marked with `all`, and there's limitations to how you can use an access that gets passed as a parameter. Due to these factors, how allocations can be used gets constrained and with Ada's support for RAII ("controlled types"), these details usually get hidden internally within types. It's not a specific block section like `unsafe`, but your unsafe memory usage is helped by the type system.