My two cents

Martin Nowak code at dawg.eu
Sat Oct 21 13:43:36 UTC 2017


On Friday, 20 October 2017 at 20:05:51 UTC, jmh530 wrote:
>> Interesting proposals, but IMHO, the only ESSENTIAL feature 
>> missing in D is the possibility to program in D using a 
>> built-in reference-counting based variant of the standard 
>> library.
>>
>
> Look at the goals for H2 2017
> https://wiki.dlang.org/Vision/2017H2
> The top three things: 1) @safety, 2) @nogc, 3) betterC. Under 
> #2, it specifically says safe reference counting. It's getting 
> worked on...

Yes, it's being worked on, but it's also a huge topic to come up 
with @safe memory management approach. It's literally about 
eradicating one of the biggest security bug classes, 
use-after-free.

Currently I'm working towards an ORM library starting at I/O 
(https://github.com/MartinNowak/io) to better inform the 
necessary design.

We already found couple of interesting litmus tests, like the 
window in iopipe.

auto window = iopipe.window;
iopipe.extend(512); // invalidates window :/
window[0]; // use after-free

Another thing that Walter previously found out is that exceptions 
are a major hassle for @nogc. I don't like the RC Exception 
solution much though, as it's a fairly specific workaround 
(https://github.com/dlang/druntime/pull/1804).

Towards that goal, making exception nesting optional and 
providing access to the current Exception in flight would allow 
to use the staticError approach in most places.
https://github.com/dlang/druntime/blob/bc832b18430ce1c85bf2dded07bbcfe348ff0813/src/core/exception.d#L683

Recently I wondered why we cannot semantically transform 
exceptions to the equivalent of function calls.

- throw Uniq!Exception; // ctor, some struct that's implicitly 
convertible to a Throwable

- catch (scope Exception e) // handler 1
{
     throw e; // basically continue to unwind
}

- catch (scope Exception e) {} // handler 2

- done unwinding, destroy thrown value

We still support gotos in catch handlers, but should be possible 
to call destructors in catch handlers anyhow.
https://github.com/dlang/druntime/pull/1804/files#diff-f3953348bb302c27a8cea926c62c02e6R69


More information about the Digitalmars-d mailing list