Re: Copying a delegate

2010-09-20 Thread Jonathan M Davis
On Monday, September 20, 2010 04:08:11 Kagamin wrote: > Jonathan M Davis Wrote: > > I don't think that there's anything Phobos can do > > about it. It's a limitation of delegates. > > If the range doesn't support copying, it shouldn't pretend to support it, > and algorithms relying on copy won't c

Re: Copying a delegate

2010-09-20 Thread Kagamin
Jonathan M Davis Wrote: > I don't think that there's anything Phobos can do > about it. It's a limitation of delegates. If the range doesn't support copying, it shouldn't pretend to support it, and algorithms relying on copy won't compile.

Re: Copying a delegate

2010-09-20 Thread Jonathan M Davis
On Monday 20 September 2010 01:08:25 Kagamin wrote: > Jonathan M Davis Wrote: > > delegate by definition has context which is not going to be copied. So, > > any functon pointer or delegate that you have must refer to a function > > which is logically pure, otherwise any algorithm that relies on sa

Re: Copying a delegate

2010-09-20 Thread Kagamin
Jonathan M Davis Wrote: > delegate by definition has context which is not going to be copied. So, any > functon pointer or delegate that you have must refer to a function which is > logically pure, otherwise any algorithm that relies on save is not going to > work > correctly. If phobos cause

Re: Copying a delegate

2010-09-19 Thread Jonathan M Davis
On Sunday 19 September 2010 17:13:14 Stewart Gordon wrote: > On 19/09/2010 04:35, Jonathan M Davis wrote: > > > > That doesn't work because you're just copying the pointer. Is there a way > > to actually do a deep copy of the delegate? I can see why this would be > > problematic if the delegate h

Re: Copying a delegate

2010-09-19 Thread Stewart Gordon
On 19/09/2010 04:35, Jonathan M Davis wrote: That doesn't work because you're just copying the pointer. Is there a way to actually do a deep copy of the delegate? I can see why this would be problematic if the delegate had reference types in its scope (since presumably, they'd have to be shallow

Copying a delegate

2010-09-18 Thread Jonathan M Davis
Is it in any way possible to copy a delegate? Take this program for example: import std.stdio; void main() { int a = 0; int func() { return a++; } int delegate() b = &func; int delegate() c = b; writeln(b()); writeln(c()); writeln(b()); } It will p