3 ms·
"performance and control of C" also means that you can make datastructures with arbitrary pointers, right? The simplest example that doesn't work in rust is a l
by sse 5y ago
"performance and control of C" also means that you can make datastructures with arbitrary pointers, right? The simplest example that doesn't work in rust is a linked list.
How can you do that when you only have multiple stacks, but no heap?
- smaddox 5y agoA singly-linked list is perfectly possible in safe Rust (https://rust-unofficial.github.io/too-many-lists/third-layout.html https://rust-unofficial.github.io/too-many-lists/third-layou...): pub struct List<T> { head: Link<T>, } type Link<T> = Option<Rc<Node<T>>>; struct Node<T> { elem: T, next: Link<T>, } Or you can replace `Rc` with `Box` if you don't need multiple links to each node. In high-level Dawn, it's basically the same as in Haskell: {data v0 List {cons Nil} {cons v0 (v0 List) Cons}} The first compiler will be quite simple and will produce roughly the equivalent of the above Rust implementation. As for cyclic doubly-linked lists and arbitrary cyclic graphs, I'll describe how those will work in a future post.