I didn't even know it was possible, now I want to learn what a linked list looks like without using unsafe
-
-
Replying to @andy_kelley @RichFelker and
use Rc and Weak Presumably y'all are talking about doubly linked lists, singly linked lists are possible to do efficiently in safe code
4 replies 0 retweets 6 likes -
Replying to @ManishEarth @andy_kelley and
There's also the possibility of using non-pointer references to represent the graph, such as indices into an array or some other pool data structure that holds the nodes
4 replies 0 retweets 8 likes -
Replying to @jckarter @ManishEarth and
This is the right answer in practice, if LinkedList<T> doesn’t work for you.
1 reply 0 retweets 2 likes -
I mean, for 99.9% of "practice" the right answer is "don't use a linked list", but for the remaining 0.1% ...
3 replies 0 retweets 3 likes -
Replying to @stephentyrone @pcwalton and
(More generally, for 99.9% of "data structures that you believe require unsafe" the right answer is "use indices instead of pointers, if you must.")
1 reply 0 retweets 4 likes -
Replying to @stephentyrone @pcwalton and
This is kinda true, but on the flip side it reinvents UAF.
1 reply 0 retweets 4 likes -
Replying to @RichFelker @stephentyrone and
The whole point (IMO; other aspects like bounds checking are relatively easier to solve) of advanced memory-safety in Rust is eliminating UAF - making it so there's no such thing as references to freed objects that can alias new unrelated objects.
1 reply 0 retweets 1 like -
Replying to @RichFelker @stephentyrone and
If you just use indices, now your indices are outside of that regime and can index a slot that's been freed and reused for something new. You just recreated C on top of Rust. Yay.
3 replies 0 retweets 2 likes -
Replying to @RichFelker @pcwalton and
You can invalidate indices by e.g. incrementing a generation field, since all accesses get mediated through the containing object anyway. This has some performance cost, but mostly eliminates this class of bugs.
2 replies 0 retweets 4 likes
BTW, Catherine West’s talk goes into this:https://www.youtube.com/watch?v=P9u8x13W7UE …
-
-
Replying to @pcwalton @stephentyrone and
I recall some interesting points (both pros & cons) on ECS-like design in the code generation context (in
@Sunfishcode's Rustc Lecture; "Cranelift Datastructures" around 9m16s): https://www.youtube.com/watch?v=9OIA7DTFQWU&t=9m16s … (I wonder how did the arena vs. ECS experiment work out in retrospect?)0 replies 0 retweets 7 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.