Why std.array : array needs pure postblit?

Steven Schveighoffer schveiguy at yahoo.com
Fri Jun 15 14:24:16 UTC 2018


On 6/15/18 7:56 AM, Andrea Fontana wrote:
> On Friday, 15 June 2018 at 11:48:59 UTC, Andrea Fontana wrote:
>> On Friday, 15 June 2018 at 11:25:49 UTC, Basile B. wrote:
>>
>>>> Hello, i've tested locally and it can works by making 
>>>> `Appender.reserve()` and `Appender.ensureAddable()` function templates.
>>>>
>>
>> That was my idea too. But I wonder if pureness of reserve and 
>> ensureAddable have a particular reason.
> 
> My point is: if we remove pure from those functions it is inferred , 
> isn't it? Why does we need to force it there?

Best way to check is to look in git history to see why it was added.

https://github.com/dlang/phobos/pull/1337

Looks like the idea is to make pure and @safe appending work.

It's quite old (2013), so it's possible that attribute inference wasn't 
up to snuff back then, but works OK now.

Make sure you put in test cases that show pure @safe formatting still 
works after your changes.

-Steve


More information about the Digitalmars-d-learn mailing list