33 ms·
Does this change affects managed box? Or it only affect owned box?
by dengnan 12y ago
Does this change affects managed box? Or it only affect owned box?
- steveklabnik 12y agoYou'll allocate a managed box with let x = box (GC) 5; if my memory serves. The argument to `box` defaults to HEAP, so these are the same: let x = box (HEAP) 5; let x = box 5; And of course, boxing an integer is silly. This is just for illustration. The @ for managed boxes has been removed from the language for a while now. It's not technically gone because there's one or two instances in the compiler, IIRC, but it should be gone Real Soon Now.
- masklinn 12y ago> You'll allocate a managed box with let x: box (Gc) 5; It's GC in full uppercase FWIW, it's a static marker[0] not the type name. And the syntax already works in 0.10 (although funnily enough only HEAP and GC exist, no e.g. RC) > The argument to `box` defaults to HEAP, so these are the same: Yep[1]. [0] http://static.rust-lang.org/doc/0.10/std/gc/index.html http://static.rust-lang.org/doc/0.10/std/gc/index.html [1] http://static.rust-lang.org/doc/0.10/std/owned/index.html http://static.rust-lang.org/doc/0.10/std/owned/index.html
- steveklabnik 12y agoThanks, I've uppercased it.
- dengnan 12y agoThanks for the explanation! This change makes the code more clear to me. When I first read some rust code, those ~ and @ are annoying because I don't know their meaning and hard to search them for a explanation. The box keyword is a much better way for developers.
- steveklabnik 12y agoThank you. That's exactly our thought process too, though there is some reasonable disagreement about it.
- slight 12y agoI've been reading a bunch of tutorials and such, including the official one, about Rust recently and you'd get the impression that using unique pointers were the norm. This discussion seems to suggest they should be generally avoided. Now I'm not sure if I've just been massively misreading everything (I come from a background in GC languages) or whether the messaging about usage is way off.
- steveklabnik 12y agoWell, the official pointer tutorial, which I wrote, says right up front that you should prefer stack allocation: http://static.rust-lang.org/doc/master/guide-pointers.html http://static.rust-lang.org/doc/master/guide-pointers.html Unique pointers are one of Rust's newest, shiniest features, so they do get talked about a lot. Probably disproportionally so. Honestly, it's probably that the docs are still coming together. The tutorial is notoriously poor, Mozilla has hired someone to work on it, but the fixes haven't surfaced yet.
- slight 12y agoRe-read the pointer tutorial and yes I've clearly mis-remembered that so apologies! You're probably right that there's just a lot of discussion about them at the moment. Anyway I'm very excited about Rust, really looking forward to 1.0.
- slight 12y agoI've been reading a bunch of tutorials and such, including the official one, about Rust recently and you'd get the impression that using unique pointers were the norm. This discussion seems to suggest they should be generally avoided. Now I'm not sure if I've just been massively misreading everything (I come from a background in GC languages) or whether the messaging about usage is way off.