Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am wondering what the Ada equivalent of affine types is. What is the feature that solves the problem that affine types solve in Rust.


The SPARK subset of Ada^1 has a similar kind of move semantics for pointer types^2.

1: SPARK is a formally verifiable subset of Ada: https://en.wikipedia.org/wiki/SPARK_(programming_language)

2: https://arxiv.org/pdf/1805.05576


Limited controlled types probably come closest.

https://learn.adacore.com/courses/advanced-ada/parts/resourc...


Right from https://www.adacore.com/languages/spark, under the title Memory Safety:

Through a combination of mitigation of dynamic memory usage, borrow-checking analysis and advanced formal proof, SPARK formally demonstrates absence of memory issues such as use after free, access to uninitialized memory or memory leaks and corruption.


There is none as far as affine types go, even is there is a parallel to be made with limited types, but they don’t serve the same purpose.

The way Ada generally solves the same problem is by allowing much more in terms of what you can give a stack lifetime to, return from a function, and pass by parameters to functions.

It also has the regular « smart pointer » mechanisms that C++ and Rust also have, also with relatively crappy ergonomics




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: