std.allocator.allocate(0) -> return null or std.allocator.allocate(1)?

via Digitalmars-d digitalmars-d at puremagic.com
Fri May 15 10:25:39 PDT 2015


On Friday, 15 May 2015 at 17:01:26 UTC, Andrei Alexandrescu wrote:
> On 5/15/15 9:44 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= 
> <schuetzm at gmx.net>" wrote:
>> Ha! Two fools, one thought :-)
>
> It's a nice idea but as Vladimir mentioned expand(), 
> reallocate(), free() - all need now to worry about checking two 
> singular values instead of one.
>
> Since there's a long-established tradition that reallocate() 
> and free() accept a null pointer, we can't (and probably 
> shouldn't) change that. So I'm thinking in a way null as a 
> singular value comes for "free".

Yes, and std.allocator is a new piece of software, which means we 
can choose what makes sense and don't need to worry about 
compatibility. It just needs to be clearly defined.


More information about the Digitalmars-d mailing list