On 03/03/2014 07:46 PM, comex wrote:
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.
I assume you take issue not with the leading sentence above, but with those following. > 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). ...
For temporary references in C++ code, I prefer to use references. But we do need actual raw pointers to managed (sub)objects as arguments to foreign C functions. There, C++ and Rust coders are in the same boat. Both depend on the C function not to keep a copy of the unsafely-issued borrowed pointer. C++ does allow a reference to last longer than the referent, and that's worth calling attention to.
In Rust, many of the situations where C++ uses raw pointers allow use of borrowed pointers, which are safe and have no overhead.
There are certainly cases in either language where nothing but a pointer will do. The problem here is to present examples that are simple enough for presentation, not contrived, and where Rust has the clear advantage in safety and (ideally) clarity. For such examples I'm going to insist on a competent C++ coder if we are not to drive away our best potential converts. Nathan Myers [email protected] _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
