Rust style memory management
So I saw this video: https://air.mozilla.org/guaranteeing-memory-safety-in-rust/ and was amazed. Is there any way we can implement this in D? What language extensions would be required? My idea on implement this would be to add 3 new pointer (and array) types : [owned,shared immutable,borrow mutable] and depend on casting raw pointers to the new types. Thoughts?
Re: Rust style memory management
Try using the -dip25 switch to dmd, it does one more step in D toward making a borrow thingy. Nowhere near the level Rust does it, but combined with other library things like destructors, prohibiting copying, etc., it can kinda make a owned thing with borrowed bits.
Re: Rust style memory management
On Saturday, 12 September 2015 at 20:17:04 UTC, Freddy wrote: So I saw this video: https://air.mozilla.org/guaranteeing-memory-safety-in-rust/ and was amazed. Is there any way we can implement this in D? What language extensions would be required? My idea on implement this would be to add 3 new pointer (and array) types : [owned,shared immutable,borrow mutable] and depend on casting raw pointers to the new types. Thoughts? There's been: http://wiki.dlang.org/User:Schuetzm/scope1 http://wiki.dlang.org/User:Schuetzm/scope2 http://wiki.dlang.org/User:Schuetzm/scope3 And at least one earlier proposal that's been accepted already. It requires the '@safe' annotation to work and is quite limited to anything more general. Although the basic opinion was that it covered a large proportion of the inherently unsafe cases that Rust aims to cover compared to C++ or unsafe D (but Rust's approach is more 'safe by proof' vs D's 'safe by prohibiting known unsafe').
Re: Rust style memory management
On Saturday, 12 September 2015 at 20:17:04 UTC, Freddy wrote: So I saw this video: https://air.mozilla.org/guaranteeing-memory-safety-in-rust/ and was amazed. Is there any way we can implement this in D? What language extensions would be required? My idea on implement this would be to add 3 new pointer (and array) types : [owned,shared immutable,borrow mutable] and depend on casting raw pointers to the new types. Thoughts? There is something in std.typecons http://dlang.org/phobos/std_typecons.html Never tried and didnt get into details, but sounds something like rust
Re: Rust style memory management
On Saturday, 12 September 2015 at 23:21:48 UTC, welkam wrote: On Saturday, 12 September 2015 at 20:17:04 UTC, Freddy wrote: So I saw this video: https://air.mozilla.org/guaranteeing-memory-safety-in-rust/ and was amazed. Is there any way we can implement this in D? What language extensions would be required? My idea on implement this would be to add 3 new pointer (and array) types : [owned,shared immutable,borrow mutable] and depend on casting raw pointers to the new types. Thoughts? There is something in std.typecons http://dlang.org/phobos/std_typecons.html Never tried and didnt get into details, but sounds something like rust No that's can't provide the guarantee that are wanted here. You can't provides these guarantee without language support.
Re: Rust style memory management
On Saturday, 12 September 2015 at 20:33:39 UTC, Adam D. Ruppe wrote: Try using the -dip25 switch to dmd, it does one more step in D toward making a borrow thingy. Nowhere near the level Rust does it, but combined with other library things like destructors, prohibiting copying, etc., it can kinda make a owned thing with borrowed bits. I really wish we don't move that way. dip25 is at best a glorious hack and the kind of things that incrase language complexity without giving much in return.