Given the recent addition of lifetimes (#642), the next question is: what about ownership?
An interesting approach to ownership is to try and leverage the verification system for this. Here's an example (using template syntax from #540):
template
type unique is (&T r) where |>r<| == 1
Here, we've defined the concept of a unique pointer. The syntax |> r <| returns the number of inbound references to the item referred to by r. Since the constraint ensures that there is only one inbound reference, we know r is a unique reference.
This raises the further question: what else could we do with this syntax?
Given the recent addition of lifetimes (#642), the next question is: what about ownership?
An interesting approach to ownership is to try and leverage the verification system for this. Here's an example (using template syntax from #540):
Here, we've defined the concept of a unique pointer. The syntax
|> r <|
returns the number of inbound references to the item referred to byr
. Since the constraint ensures that there is only one inbound reference, we knowr
is a unique reference.This raises the further question: what else could we do with this syntax?