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

Linear and uniqueness types sort of collapse into the same thing when an object is required to stay linear or unique for its entire life cycle.

They become distinct, and sort of dual to each other, when you relax this restriction: linearity ensures that no copies or aliases are produced going forward, while uniqueness ensures that no copies or aliases have ever been produced in the past.

In other words, if you call a function that is linear in its parameter, you know it won't form any additional copies of the argument, but the function can't assume it has the only reference to that argument, so it can't e.g. update it destructively. Conversely, a function that takes a unique parameter can make that assumption, but its caller can no longer assume that the argument it passed in is unique.

See also this recent paper on the two: https://granule-project.github.io/papers/esop22-paper.pdf



Very informative, thank you.




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

Search: