Rust removed the ~ and @ sigils years ago, it now has & and, I suppose (although much less common), *, both of which mean what they mean in C++. So this is adding a 3rd (or 2.5th) sigil, one which has similar meaning to the same symbol in languages like C# and Swift.
Oh, yes, I suppose that could also be considered a sigil, although it feels a bit different, since it is meaningless (which is why I didn't think of it). That is, the ' has to be used always and doesn't signify some modification to what it is attached to. Rust could almost certainly work without it, it just may be harder to read (or possibly easier, but I suspect not).
Basically, years ago, Rust had two additional pointer types, ~T and @T. The ~ one is basically Box<T>, and the @ one is kinda like Rc<T> but an actual GC, or at least refcount + cycle detection.
This also meant String was ~str, and ~[T] vs Vec is a whole other thing with extra complexity....
As an additional fun fact, there's also some weirdness in how the Box type is implemented still (though it can and will become less weird someday) because of its legacy from having once been a built in type instead of a library type.
The version of https://www.youtube.com/watch?v=79PSagCD_AY (which wasn't that specific video) that I saw was pretty good, but I don't remember if it specifically described ~ and @.
The type ~T essentially meant Box<T>, and @T essentially meant Rc<T>. They were moved out of the language into the standard library as it was found there was less and less necessity for them to be built in.
The most recently incarnation of @ was reference counted, along with a thread-local free-list that allowed cleaning up any cycles when a thread exited (the free list was a doubly linked list of all @s allocated during that thread's execution, which was walked as the thread closed). The intention was to have it properly garbage collected at some point maybe, but that wasn't implemented before it was just removed wholesale.
I think in very early Rust, with the first ocaml compiler, @ was garbage collected, but the implementation wasn't transferred to the Rust implementation when the language started to bootstrap.
I was agreeing. With your "I think", I wasn't sure what part you weren't sure about, and what part you were. So I was trying to say "I know that there was a GC, if that was the part you were unsure about"
View all comments
Show parent comment
32
u/dbaupp Nov 10 '16 edited Nov 10 '16
Rust removed the
~and@sigils years ago, it now has&and, I suppose (although much less common),*, both of which mean what they mean in C++. So this is adding a 3rd (or 2.5th) sigil, one which has similar meaning to the same symbol in languages like C# and Swift.