logoalt Hacker News

bananaflagtoday at 10:09 AM3 repliesview on HN

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.


Replies

ajxstoday at 11:26 AM

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

fweimertoday at 10:29 AM

Limited controlled types probably come closest.

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

Raphael_Amiardtoday at 11:20 AM

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