Proposal: Exceptions and @nogc

Jack Stouffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 4 08:21:50 PDT 2017


On Tuesday, 4 April 2017 at 00:45:08 UTC, Moritz Maxeiner wrote:
> AFAICT this solution will end up with everyone always calling 
> theAllocator.dispose when catching from Phobos.

Yes, because you can no longer assume that the GC is being used, 
as all current Phobos code does.

Here's the thing, this problem misses the forrest for the trees. 
Focusing on exceptions is not seeing the broader problem of the 
user being at the mercy of Phobos devs with their choices of 
allocations. Exceptions are one aspect of the problem of 
allocation in a standard library with multiple allocation methods 
available. It's only as a matter of convenience that we've been 
using the GC for everything when stack allocation isn't enough. 
If we want to compete with Rust and C++* need a clean way to let 
the user control memory throughout their program.

As already pointed out, this is one ad-hoc solution to a specific 
problem rather than a holistic solution.


* to be honest, I would be fine if it was concluded that this 
isn't what we want to compete with. Java and C# didn't mostly 
replace C++ by being "C++ but slightly different". They won 
because they were something different that allowed you to get 
shit done. What does D want to be, a better C++ or a better 
language?

I don't think it's possible to have a clean language + std 
library and have the same amount of power as C++, the GC is just 
to convenient and takes off so much cognitive load. If we want to 
compete with C++ with Phobos, Phobos will need to become more 
ugly but more flexible.


More information about the Digitalmars-d mailing list