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 compile.
Except that you don't know what is in a delegate, or it wouldn't be a delegate. Many delegates can be reused just fine and thus "copied" because they are logically pure. Others can't be. If you have a range based on a delegate, unless you know every single function that could be used as the delegate, you have no way of knowing whether the delegate is logically pure. And even then, you'd only know it because you knew what the functions did; the compiler couldn't enforce it. So, you can have a range which properly supports copying as long as its delegate is logically pure, but you can't use the compiler to enforce that the delegate be logically pure. There's no way for Phobos to avoid the problem. The only way to completely avoid the problem is not to have ranges which are generated with delegates, but that would eliminate a lot of useful ranges. - Jonathan M Davis
