Why is `scope` planned for deprecation?

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 12 07:57:20 PST 2014


On 11/11/2014 18:01, bearophile wrote:
> I agree it's a very important topic (more important/urgent than the GC,
> also because it reduces the need of the GC). But I think Walter thinks
> this kind of change introduces too much complexity in D (despite it may
> eventually become inevitable for D once Rust becomes more popular and
> programmers get used to that kind of static enforcement).

I think Rust's lifetimes would be a huge change if ported to D. In Rust 
user types often need annotations as well as function parameters. People 
tend to want Rust's guarantees without the limitations. I think D does 
need some kind of scope attribute verification, but we need to throw out 
some of the guarantees Rust makes to get an appropriate fit for existing 
D code.

For example, taking a mutable borrowed pointer for a variable means you 
can't even *read* the original variable whilst the pointer lives. I 
think no one would try to make D do that, but Rust's reason for adding 
it is actually memory safety (I don't quite understand it, but it 
involves iterator invalidation apparently). It's possible their feature 
can be refined, but basically 'mut' in Rust really means 'unique'.


More information about the Digitalmars-d mailing list