On Friday, 4 July 2014 at 19:46:40 UTC, Remo wrote:
Who want to use C-style memory management today ?
How about C++ style memory management, is this easy to this in D2
now ?

The big problem with that is "C++ style memory management" implies we're going to have new/delete which AFAIK delete is depreciated and new is currently hardcoded to use the GC.

But malloc/free works, so C-style memory management is already here.

IMHO @nogc is the right direction.

But it would be great if one could compile at least this code.
int main(string[] argv) @nogc {
   writeln("Hello D-World!");
   return 0;
}

I'm sure we'll get there. There's some decent ground to cover before we can get that, though. We need to make it so phobos code doesn't need to allocate exceptions everywhere first (which should be doable). Plus we'll also need to keep having exceptions that have good error messages. I've posted a "proof of concept" of such a thing in the IRC, but here it is as well (obviously, it's really rough because I'm just throwing ideas together in a blender at this point...):
https://gist.github.com/Zshazz/47ed52c3246e5348062a

I'm also working on a few helpers for @nogc code that'll make the above more concise and readable (again, *very* preliminary ... SemiStackSink is a mixin template in here, but that's only because I was trying out weird ideas; as it stands now it should just be a simple template struct):
https://gist.github.com/Zshazz/fed0400674f034e09495

As a bonus, SemiStackSink working on 200_000_000 chars takes around 1/6 of the time as a pure GC implementation. Obviously for very small numbers of chars (<60), it's basically instant because it allocates on the stack at that point.

So yeah, 2.066 will probably spur more work in code that doesn't need the GC. Once std.allocator lands and we start developing usage patterns on that, the amount of code that needs the GC will shrink even further.

Reply via email to