On Mon, Mar 3, 2014 at 10:17 PM, Nathan Myers <[email protected]> wrote: > It's clear that we need someone fully competent in C++ to > code any comparisons. In C++, one is only ever motivated to > ("unsafely") extract the raw pointer from a smart pointer when > only a raw pointer will do. This is exactly as likely to happen > in Rust as in C++, and in exactly the same places. Where it is > needed, Rust offers no safer alternative.
This is simply wrong. Most C++ code I've seen frequently uses raw pointers in order to pass around temporary references to objects that are not reference counted (or even objects that are reference counted, to avoid the overhead for simple copies). You can mostly eschew this by using shared_ptr for everything (although there are caveats, such as 'this' effectively always being a raw pointer), but that introduces significant overhead (especially for shared_ptr because it uses atomic reference counting, but some even for a nonatomic version), and from what I've seen it's common to recommend unique_ptr instead [1] because it clarifies lifetimes. In Rust, many of the situations where C++ uses raw pointers allow use of borrowed pointers, which are safe and have no overhead. [1] http://programmers.stackexchange.com/questions/133302/stdshared-ptr-as-a-last-resort _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
