rust reaction to walter's talk on interfacing to C++

QAston via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 24 05:00:30 PDT 2016


On Tuesday, 22 March 2016 at 11:00:44 UTC, Jonathan M Davis wrote:
> That's funny. I would have said that those were _advantages_ 
> for D. D's constness can certainly be unwieldy (some sort of 
> equivalent to C++ mutable would be a very welcome addition if 
> we could pull it off), but whatever flaws D's const may have, 
> the transitivity is a huge plus overall IMHO, and I would have 
> said that the struct/class split was a huge win. It properly 
> segregates the inheritance stuff to reference types while not 
> forcing all user-defined types of any complexity to be 
> reference types.
>
> So, while I'm quite sure that Rust has advantages over D, I 
> would not have listed those among them.
>
> - Jonathan M Davis

Rust doesn't need D-style transitive const because it can be 
replicated using variable bindings and ownership. When you create 
an object and only assign it immutable binding for it it's 
transitively immutable forever. Tail mutability can be achieved 
by wrapping a field in std::Cell: 
https://doc.rust-lang.org/std/cell/ . Imo much less invasive than 
D's constness.

Rust doesn't have implementation inheritance yet, so no 
class/struct split. We'll see how they deal with that, various 
proposals are made.




More information about the Digitalmars-d mailing list