Why can't I give a function's return type the scope storage class?

Atila Neves atila.neves at gmail.com
Tue Mar 19 10:19:49 UTC 2019


On Tuesday, 19 March 2019 at 03:16:04 UTC, Walter Bright wrote:
> On 3/18/2019 7:28 PM, jmh530 wrote:
>> BTW, did you see this:
>> https://atilaoncode.blog/2019/03/13/issues-dip1000-cant-yet-catch/
>
> C++ has no protection for its library types, except by 
> convention. Translating them by rote into D leaves those 
> problems intact. They need to be redesigned with D's mechanisms 
> in mind for them to be memory safe. Leaking pointers to its 
> internals is exactly that sort of issue.

I didn't translate anything, I wrote it from scratch. C++ doesn't 
even have slices!

The fact is that DIP1000 didn't prevent me from writing @safe 
code where a pointer dangled. The point of my blog was "how can 
we improve D to disallow anyone else from writing code like this 
by making it fail to compile with -dip1000?". It's got nothing to 
do with C++, the comparison was with Rust, where one can't write 
the faulty code.

Given the focus on memory safety in D without having to rely on 
the GC, I think this should be given serious consideration.


More information about the Digitalmars-d mailing list