On 12/12/2014 10:54 AM, bearophile wrote:
This code:
struct Vec { float x = 1, y = 5, z = 9; }
auto v = new Vec(void);

Means having defined a struct with explicitly statically defined fields,
and then allocate one of it on the heap without initializing its fields.
It's equivalent to:

auto v = cast(Vec*)malloc(Vec.sizeof);

D is a language with C-like syntax and static typing. It pragmatically combines efficiency, control, and modeling power, with ~~~>safety<~~ and programmer productivity.

Unsafe stuff shouldn't be simple to type and why would you need language support for a 1-liner?

ref T uninitializedAlloc(T)() @system pure nothrow
{
    return *cast(T*)GC.malloc(T.sizeof);
}

The only argument I can see is the asymmetry to
    Vec v = void;


Reply via email to