using std.algorithm.topN with std.range.zip fails with undefined swap
Hi, Trying to compile : import std.stdio, std.range, std.algorithm; void main() { auto a = [2.0,1.0,3.0]; struct Point { double x; } auto b = [Point(4.0), Point(5.0), Point(6.0)]; topN!(a[0] b[0])(zip(a,b),1); //sort!(a[0] b[0])(zip(a,b)); writeln(a,b); } std/algorithm.d(8225): Error: template std.algorithm.swap does not match any function template declaration. Swapping out topN with sort works just fine. I assume both sort and topN use swap, is there a reason this doesn't work with topN? Thanks in advance, -- Nikhil
using std.algorithm.topN with std.range.zip fails with undefined swap
(apologies in advance if this posts multiple times, I messed up the sending email address the first time). Hi, Trying to compile : import std.stdio, std.range, std.algorithm; void main() { auto a = [2.0,1.0,3.0]; struct Point { double x; } auto b = [Point(4.0), Point(5.0), Point(6.0)]; topN!(a[0] b[0])(zip(a,b),1); //sort!(a[0] b[0])(zip(a,b)); writeln(a,b); } std/algorithm.d(8225): Error: template std.algorithm.swap does not match any function template declaration. Swapping out topN with sort works just fine. I assume both sort and topN use swap, is there a reason this doesn't work with topN? Thanks in advance, -- Nikhil - Nikhil Padmanabhan nikhil.padmanab...@yale.edu
segfault when using std.parallelism and std.process.executeShell
Hi, The following code dies with a segfault : import std.stdio, std.parallelism, std.process; void main() { auto a=[hello,world,goodbye]; foreach(s; parallel(a,1)) { auto ls=executeShell(echo ~s); writeln(ls.output); } } both in ldc and dmd. Removing either the parallel or running something other than executeShell (eg. just doing a writeln) works, which suggests to me that it's something about the way executeShell is interacting with parallel. Pulling it up in lldb, I get : * thread #2: tid = 0x16738e6, 0x000100039198 test`D3std7process7environFNbNdNeZxPPa + 20, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x000100039198 test`D3std7process7environFNbNdNeZxPPa + 20 Any thoughts on what might be going wrong? Is executeShell somehow not threadsafe? Thanks! -- Nikhil
Compile error using synchronized in ldc (but not dmd)
Hello, The following code snippet fails to compile on ldc2 (0.12.1), but successfully compiles on dmd 2.064.2 : struct Particle { double x,y,z,w,x2; this(double[] arr) { x = arr[0]; y = arr[1]; z=arr[2]; w=arr[3]; x2 = x*x + y*y + z*z; } } synchronized class SyncArray { private Particle[] buf; void push(Particle[] arr1) { buf.length = arr1.length; buf[] = arr1[]; } Particle[] pop() { auto _tmp = new Particle[buf.length]; _tmp[] = buf[]; buf = null; return _tmp; } } The error message in ldc2 : test.d(14): Error: cannot implicitly convert expression (arr1[]) of type Particle[] to const(shared(Particle)[]) test.d(19): Error: cannot implicitly convert expression (this.buf[]) of type shared(Particle)[] to const(Particle[]) What am I doing wrong here? Thanks in advance! -- Nikhil P.S. I've been enjoying coding in D a lot -- many thanks to the entire D community!
Re: Compile error using synchronized in ldc (but not dmd)
Just a quick follow-up : replacing the array operation by a foreach works around this issue, but I don't understand why it failed in the first place. On Monday, 9 December 2013 at 04:26:01 UTC, Nikhil Padmanabhan wrote: Hello, The following code snippet fails to compile on ldc2 (0.12.1), but successfully compiles on dmd 2.064.2 : struct Particle { double x,y,z,w,x2; this(double[] arr) { x = arr[0]; y = arr[1]; z=arr[2]; w=arr[3]; x2 = x*x + y*y + z*z; } } synchronized class SyncArray { private Particle[] buf; void push(Particle[] arr1) { buf.length = arr1.length; buf[] = arr1[]; } Particle[] pop() { auto _tmp = new Particle[buf.length]; _tmp[] = buf[]; buf = null; return _tmp; } } The error message in ldc2 : test.d(14): Error: cannot implicitly convert expression (arr1[]) of type Particle[] to const(shared(Particle)[]) test.d(19): Error: cannot implicitly convert expression (this.buf[]) of type shared(Particle)[] to const(Particle[]) What am I doing wrong here? Thanks in advance! -- Nikhil P.S. I've been enjoying coding in D a lot -- many thanks to the entire D community!