Uh... destructors?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Feb 23 05:04:49 PST 2011


On 2/22/11 3:14 PM, Steven Schveighoffer wrote:
> On Tue, 22 Feb 2011 15:48:42 -0500, %u <wfunction at hotmail.com> wrote:
>
>>> D pure functions are significantly different than this definition
>> (as of recent times, when weak-pure was added).
>>> Essentially, a pure function cannot access global variables.
>> However, it can access variables referred to via a member of the
>> object instance.
>>> i.e. this is a valid pure function:
>> class C
>> {
>> int x;
>> pure void foo() { x++; }
>> }
>>
>> I... did not know that. But even in that case, pure wouldn't make much
>> sense, because doing anything like freeing memory or closing a file
>> handle affects global variables (whether directly in the runtime or
>> indirectly in the OS)... right?
>
> Freeing and allocating memory is fair game for pure functions.

I don't think freeing memory is pure.

Andrei


More information about the Digitalmars-d mailing list