Re: forcing weak purity

2012-05-24 Thread Don Clugston
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

Re: forcing weak purity

2012-05-24 Thread Steven Schveighoffer
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

Re: forcing weak purity

2012-05-24 Thread H. S. Teoh
On Thu, May 24, 2012 at 08:56:25AM -0400, Steven Schveighoffer wrote: [...] 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 agree. Purity only exists at a certain

Re: forcing weak purity

2012-05-23 Thread Don Clugston
On 23/05/12 07:05, Mehrdad wrote: We should make 'pure' mean strongly pure. For weakly pure, we could introduce the 'doped' keyword :-D No, the keyword should be more like @noglobal I wish people would stop using this weak purity / strong purity terminology, it's very unhelpful. (And it's

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 06:00:11 -0400, Don Clugston d...@nospam.com wrote: On 23/05/12 07:05, Mehrdad wrote: We should make 'pure' mean strongly pure. For weakly pure, we could introduce the 'doped' keyword :-D No, the keyword should be more like @noglobal Well, it's actually

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Tue, 22 May 2012 23:31:59 -0400, Alex Rønne Petersen a...@lycus.org wrote: On 23-05-2012 05:22, Steven Schveighoffer wrote: This solution looks crappy to me: void gc_collect(void *unused = null); BTW, any compiler with alias analysis and LTO might even decide to remove the call even

Re: forcing weak purity

2012-05-23 Thread Artur Skawina
On 05/23/12 05:22, Steven Schveighoffer wrote: it has no parameters and no return, marking it as pure makes it strong pure, and an optimizing compiler can effectively remove the call completely! Arguably a pure function not returning a value doesn't make sense... D's definition of pure makes

Re: forcing weak purity

2012-05-23 Thread Artur Skawina
On 05/23/12 13:45, Steven Schveighoffer wrote: On Tue, 22 May 2012 23:31:59 -0400, Alex Rønne Petersen a...@lycus.org wrote: On 23-05-2012 05:22, Steven Schveighoffer wrote: This solution looks crappy to me: void gc_collect(void *unused = null); BTW, any compiler with alias analysis

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could technically run on any memory allocation (which is already allowed in pure

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 13:48, Artur Skawina wrote: On 05/23/12 05:22, Steven Schveighoffer wrote: it has no parameters and no return, marking it as pure makes it strong pure, and an optimizing compiler can effectively remove the call completely! Arguably a pure function not returning a value doesn't

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 14:21, deadalnix wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could technically run on any memory

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 08:21:42 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could

Re: forcing weak purity

2012-05-23 Thread Don Clugston
On 23/05/12 05:22, Steven Schveighoffer wrote: I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could technically run on any memory allocation (which is already allowed in pure

Re: forcing weak purity

2012-05-23 Thread bearophile
Don Clugston: The real question being asked is, do we need something for logical purity? You mean something like @trusted_pure? Note that we need the same thing for caching. Regarding caching, memoization, weak references, and related things, I prefer a more principled approach, like

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 15:46, deadalnix wrote: Le 23/05/2012 14:32, Alex Rønne Petersen a écrit : On 23-05-2012 14:21, deadalnix wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 14:32, Alex Rønne Petersen a écrit : On 23-05-2012 14:21, deadalnix wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure,

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 14:35, Steven Schveighoffer a écrit : On Wed, 23 May 2012 08:21:42 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 09:17:43 -0400, Don Clugston d...@nospam.com wrote: On 23/05/12 05:22, Steven Schveighoffer wrote: I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 15:47, Alex Rønne Petersen a écrit : On 23-05-2012 15:46, deadalnix wrote: Le 23/05/2012 14:32, Alex Rønne Petersen a écrit : On 23-05-2012 14:21, deadalnix wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a dilemma. Alex Rønne Petersen has a pull

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 15:52, Steven Schveighoffer a écrit : What if memory is tight, and the only way to get memory for this new allocation is to collect from the main heap? This seems an odd limitation, since strong-pure functions would not be affected by collecting in the main heap *at all*. -Steve

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 09:52:31 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 14:35, Steven Schveighoffer a écrit : Yes. Memory allocation and deallocation from a global heap is by definition an impure operation (it affects global state). However, we must make exceptions because

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 15:17, Don Clugston wrote: On 23/05/12 05:22, Steven Schveighoffer wrote: I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could technically run on any memory

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 15:57, Steven Schveighoffer a écrit : On Wed, 23 May 2012 09:52:31 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 14:35, Steven Schveighoffer a écrit : Yes. Memory allocation and deallocation from a global heap is by definition an impure operation (it affects global

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 15:55, deadalnix wrote: Le 23/05/2012 15:47, Alex Rønne Petersen a écrit : On 23-05-2012 15:46, deadalnix wrote: Le 23/05/2012 14:32, Alex Rønne Petersen a écrit : On 23-05-2012 14:21, deadalnix wrote: Le 23/05/2012 05:22, Steven Schveighoffer a écrit : I have come across a

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 09:56:58 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 15:52, Steven Schveighoffer a écrit : What if memory is tight, and the only way to get memory for this new allocation is to collect from the main heap? This seems an odd limitation, since strong-pure

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 16:03, deadalnix wrote: Le 23/05/2012 15:57, Steven Schveighoffer a écrit : On Wed, 23 May 2012 09:52:31 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 14:35, Steven Schveighoffer a écrit : Yes. Memory allocation and deallocation from a global heap is by definition

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 10:03:01 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 15:57, Steven Schveighoffer a écrit : On Wed, 23 May 2012 09:52:31 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 14:35, Steven Schveighoffer a écrit : Yes. Memory allocation and deallocation

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 16:03, deadalnix a écrit : Le 23/05/2012 15:57, Steven Schveighoffer a écrit : On Wed, 23 May 2012 09:52:31 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 14:35, Steven Schveighoffer a écrit : Yes. Memory allocation and deallocation from a global heap is by

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 16:42, deadalnix wrote: Le 23/05/2012 16:03, deadalnix a écrit : Le 23/05/2012 15:57, Steven Schveighoffer a écrit : On Wed, 23 May 2012 09:52:31 -0400, deadalnix deadal...@gmail.com wrote: Le 23/05/2012 14:35, Steven Schveighoffer a écrit : Yes. Memory allocation and

Re: forcing weak purity

2012-05-23 Thread Don Clugston
On 23/05/12 15:56, Alex Rønne Petersen wrote: On 23-05-2012 15:17, Don Clugston wrote: On 23/05/12 05:22, Steven Schveighoffer wrote: I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 17:29, Don Clugston wrote: On 23/05/12 15:56, Alex Rønne Petersen wrote: On 23-05-2012 15:17, Don Clugston wrote: On 23/05/12 05:22, Steven Schveighoffer wrote: I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 11:41:00 -0400, Alex Rønne Petersen a...@lycus.org wrote: On 23-05-2012 17:29, Don Clugston wrote: Not so. It's impossible for anything outside of a strongly pure function to hold a pointer to memory allocated by the pure function. Not sure I follow: immutable(int)*

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 17:56, Steven Schveighoffer wrote: On Wed, 23 May 2012 11:41:00 -0400, Alex Rønne Petersen a...@lycus..org wrote: On 23-05-2012 17:29, Don Clugston wrote: Not so. It's impossible for anything outside of a strongly pure function to hold a pointer to memory allocated by the pure

Re: forcing weak purity

2012-05-23 Thread Steven Schveighoffer
On Wed, 23 May 2012 12:22:39 -0400, Alex Rønne Petersen a...@lycus.org wrote: On 23-05-2012 17:56, Steven Schveighoffer wrote: On Wed, 23 May 2012 11:41:00 -0400, Alex Rønne Petersen a...@lycus..org wrote: On 23-05-2012 17:29, Don Clugston wrote: Not so. It's impossible for anything

Re: forcing weak purity

2012-05-23 Thread deadalnix
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 !

Re: forcing weak purity

2012-05-23 Thread deadalnix
Le 23/05/2012 18:22, Alex Rønne Petersen a écrit : On 23-05-2012 17:56, Steven Schveighoffer wrote: On Wed, 23 May 2012 11:41:00 -0400, Alex Rønne Petersen a...@lycus..org wrote: On 23-05-2012 17:29, Don Clugston wrote: Not so. It's impossible for anything outside of a strongly pure

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
On 23-05-2012 19:19, deadalnix wrote: Le 23/05/2012 18:22, Alex Rønne Petersen a écrit : On 23-05-2012 17:56, Steven Schveighoffer wrote: On Wed, 23 May 2012 11:41:00 -0400, Alex Rønne Petersen a...@lycus..org wrote: On 23-05-2012 17:29, Don Clugston wrote: Not so. It's impossible for

Re: forcing weak purity

2012-05-23 Thread Alex Rønne Petersen
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

forcing weak purity

2012-05-22 Thread Steven Schveighoffer
I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could technically run on any memory allocation (which is already allowed in pure functions), and it runs in a context that

Re: forcing weak purity

2012-05-22 Thread Alex Rønne Petersen
On 23-05-2012 05:22, Steven Schveighoffer wrote: I have come across a dilemma. Alex Rønne Petersen has a pull request changing some things in the GC to pure. I think gc_collect() should be weak-pure, because it could technically run on any memory allocation (which is already allowed in pure

Re: forcing weak purity

2012-05-22 Thread Mehrdad
We should make 'pure' mean strongly pure. For weakly pure, we could introduce the 'doped' keyword :-D