Jonathan Blow demo #2

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 12 03:53:57 PST 2014


On 12/12/2014 11:42 AM, bearophile wrote:
> Martin Nowak:
>
> OK, I think that it will be enough to add a Phobos function like this
> (what's the right Phobos module to put it?)

Did you just volunteer to make a pull :)?
As usual, having a problem to find the right place myself.
Would put it close to uninitializedFill which lives in std.algorithm, yuck.
BTW, if anyone knows where initOnce should go, I'd be glad to hear.
https://github.com/D-Programming-Language/phobos/pull/2664#issuecomment-66242464

> (why isn't this @trusted?)

Can't be trusted because it returns a heap allocated struct that might 
contain uninitialized pointers. You could be more precise and make an 
overload for plain value types.

> (why isn't this returning a T*?):
>
>
>> ref T uninitializedAlloc(T)() @system pure nothrow
>> {
>>     return *cast(T*)GC.malloc(T.sizeof);
>> }

Yeah, that should return a pointer.



More information about the Digitalmars-d mailing list