On Thu, 24 May 2012 04:58:56 -0400, Don Clugston <d...@nospam.com> wrote:

On 24/05/12 02:26, Alex Rønne Petersen wrote:
On 23-05-2012 19:16, deadalnix wrote:
Le 23/05/2012 17:29, Don Clugston a écrit :
There's a huge difference between "a global collection *may* be
performed from a pure function" vs "it *must* be possible to force a
global collection from a pure function".


Thank you !

I personally disagree that this should be a rationale to not allow the
latter. D is a systems language and we really should stop trying to
pretend that it isn't. There's a reason we have a core.memory module
that lets us control the GC.


This is all about not exposing quirks of the current implementation.

The way it currently is, would get you to perform a gc before you enter the first pure function. After that, the only possible garbage to collect would have been generated from inside the pure function. And that should be very cheap to collect.

The more I think about it, the more I believe that what gc_collect does (i.e. run a full collect, or run a pure-function specific collect) is an implementation detail.

I don't think exposing gc_collect is a quirk of the current implementation, and it should be marked pure (weak purity).

This whole thread has kind of flown way off topic. Regardless of whether gc_collect should be callable from a pure function, there are other use cases for considering logically pure functions as pure (for the same reasons you can cast away const). Should we be able to force weak purity or not? If so, how to do it?

-Steve

Reply via email to