DIP77 - Fix unsafe RC pass by 'ref'

via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 12 04:03:23 PDT 2015


On Sunday, 12 April 2015 at 07:17:07 UTC, Walter Bright wrote:
> On 4/11/2015 4:33 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= 
> <schuetzm at gmx.net>" wrote:
>> http://wiki.dlang.org/User:Schuetzm/scope3#.40safety_violations_with_borrowing
>
> A quick read of this suggests it is doing the Rust model of 
> only one mutable reference at a time. Is this really viable 
> with D?

I think it is. You have to keep in mind that this is opt-in; it 
only applies to `scope` variables. I would agree that as a 
default, it wouldn't fit D at all. I think that, for all its 
usefulness, it'd be a tad too limiting for my taste if I were 
forced to use it everywhere. In Rust, it needs to be ubiquitous, 
because their goal is to get by without a GC. We on the other 
hand just want a way to make the GC easier to avoid. We also want 
to be able to use these different programming styles side by 
side, therefore an opt-in solution is good.

Besides, I too want to recommend the article Matovitch linked to, 
and Yehuda Katz' article mentioned therein, because they make a 
good point demonstrating that it gives more correctness 
guarantees than just memory safety:

http://forum.dlang.org/post/ttjzihuffrdlgqonqiwi@forum.dlang.org

It's a great building block for lots of nice things. In fact, 
it's quite likely the only way to get these guarantees once you 
look beyond reference counting.


More information about the Digitalmars-d mailing list