Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
If you mean should multiple threads access it at the same time I think it's safe as the inum used by each thread will never be the same.

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
This is specifically a fixed-length array issue? No, fixed and dynamic overflow, though I think one takes one more iteration than the other possibly to cause it.

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Joseph Rushton Wakeling
On Wednesday, 30 May 2012 at 06:06:10 UTC, Ali Çehreli wrote: pure int[] solve(const bool[] redundancy, const ushort[LEN - 1][] matrixes, const int[2^^LEN] bits, const int[] numbers) Fixed-length arrays are value types and are copied on the stack. Try passing 'bits' as 'const ref' instead of j

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Dmitry Olshansky
On 30.05.2012 20:40, Joseph Rushton Wakeling wrote: On Wednesday, 30 May 2012 at 06:06:10 UTC, Ali Çehreli wrote: pure int[] solve(const bool[] redundancy, const ushort[LEN - 1][] matrixes, const int[2^^LEN] bits, const int[] numbers) Fixed-length arrays are value types and are copied on the st

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread sclytrack
On 05/30/2012 04:33 AM, ixid wrote: Having solved Project Euler 300 I wanted to explore which of the strictly superior fold set were redundant but started getting an exception thrown after a few iterations. I've changed the offending part to try to make it as impact-free as possible (my code is

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Ali Çehreli
On 05/30/2012 06:49 AM, ixid wrote: > What happens to ref const in a multi-threaded > environment? Is it locked by the const ref function until it has > finished or can other threads modify it? Yes, other threads can modify it but it would have to be marked as 'shared' to begin with. Otherwise

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread bearophile
On Wednesday, 30 May 2012 at 13:47:32 UTC, ixid wrote: Thank you, that seems to fix it. I'd assumed that const arguments were optimized as ref any way for some reason so hadn't though to try that, hence my confusion about how more and more data was being created. 1) Time ago I have asked for

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
Then again I see how that's a silly though as I'm then expecting const to be immutable. What happens to ref const in a multi-threaded environment? Is it locked by the const ref function until it has finished or can other threads modify it?

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
Thank you, that seems to fix it. I'd assumed that const arguments were optimized as ref any way for some reason so hadn't though to try that, hence my confusion about how more and more data was being created.

Re: Exception caused by calling a pure function repeatedly

2012-05-29 Thread Ali Çehreli
On 05/29/2012 07:33 PM, ixid wrote: Having solved Project Euler 300 I wanted to explore which of the strictly superior fold set were redundant but started getting an exception thrown after a few iterations. I've changed the offending part to try to make it as impact-free as possible (my code is

Re: Exception caused by calling a pure function repeatedly

2012-05-29 Thread ixid
It seems to leak memory with each iteration of the loop taking another 100-200K until it crashes when going over 11 MB.