Re: auto ref and arrays

2012-11-28 Thread Dan
On Tuesday, 27 November 2012 at 22:09:21 UTC, Jack Applegame wrote: I don't understand why auto ref doesn't work with arrays. void test1(T)(auto ref const T[] val) {} void test2(T)(auto ref const T val) {} void main() { int b; test2(b); // OK string a; test1(a); // Error: cast(const(char

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Tuesday, 27 November 2012 at 18:04:19 UTC, Maxim Fomin wrote: I think it crashes because of using associative array. Assignment to an absent aa member causes memory allocation without proper object construction, and immediately after compiler issues call to opAssign for not-constructed ob

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Monday, 26 November 2012 at 15:44:42 UTC, Joseph Rushton Wakeling wrote: Hello all, I'm writing some code which is meant to represent a network of linked nodes. [snip] Ok, another follow up. I can reproduce your segfault using your posted code, it is included below. But the interesting th

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Maxim Fomin
On Wednesday, 28 November 2012 at 13:09:36 UTC, Dan wrote: On Monday, 26 November 2012 at 15:44:42 UTC, Joseph Rushton Wakeling wrote: Hello all, I'm writing some code which is meant to represent a network of linked nodes. [snip] Ok, another follow up. I can reproduce your segfault using you

Re: safety of move

2012-11-28 Thread Dmitry Olshansky
11/28/2012 7:19 AM, Ellery Newcomer пишет: I find myself using [abusing?] move lately: import std.algorithm; import std.stdio; struct A { const(int) i; int j; int k; } void main() { A* a = new A(); // pretend this is malloc or something // *a = A(1) A a2 = A(1);

Re: Error: SIMD vector types not supported on this platform

2012-11-28 Thread Michael
On Monday, 26 November 2012 at 22:59:49 UTC, jerro wrote: I don't know when dmd on windows will get SIMD support. I have checked windows 64 bit dmd alpha now and it already supports SIMD. Tnx ;)

Re: telnet and D

2012-11-28 Thread 1100110
On 11/27/2012 01:56 PM, maarten van damme wrote: Haven't looked at vibe.d yet because it looked more like a library for writing web apps and normal sockets should be enough. Didn't know about Tango, I'll try deciphering the original d1 module. ... I mean no offense, but that sounds painful.

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Joseph Rushton Wakeling
On 11/28/2012 02:09 PM, Dan wrote: It would be interesting to know if Joseph was doing his "testing" out in unittest or in a main. In main -- the code you saw attached to my earlier email is the code I was running. Thanks very much for your efforts at chasing down the bug!

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Wednesday, 28 November 2012 at 13:43:04 UTC, Maxim Fomin wrote: On Wednesday, 28 November 2012 at 13:09:36 UTC, Dan wrote: Actually bug is still there - changing unittest to main() does not fix program, even if it seems to run correctly. The problem with memory corruption is that it may ha

Re: path matching problem

2012-11-28 Thread Charles Hixson
On 11/27/2012 06:45 PM, jerro wrote: You could replace the inner loop with somehting like: bool excl = exclude.any!(part => name.canFind(part)); std.algorithm seems to generally be running the match in the opposite direction, if I'm understanding it properly. (Dealing with D template is alway

Apparent problem with GC not collecting on Windows

2012-11-28 Thread Ali Çehreli
A friend of mine reports that the memory usage of the following program grows continuously when compiled with dmd 2.060 and run on Windows 7 sp1 home premium 64 bit (also on Microsoft Windows [Version 6.1.7600]). If you are on Windows, could you please say whether you have the same problem. (I

Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread Dmitry Olshansky
11/28/2012 10:51 PM, Ali Çehreli пишет: A friend of mine reports that the memory usage of the following program grows continuously when compiled with dmd 2.060 and run on Windows 7 sp1 home premium 64 bit (also on Microsoft Windows [Version 6.1.7600]). If you are on Windows, could you please say

Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread 1100110
On 11/28/2012 12:57 PM, Dmitry Olshansky wrote: 11/28/2012 10:51 PM, Ali Çehreli пишет: A friend of mine reports that the memory usage of the following program grows continuously when compiled with dmd 2.060 and run on Windows 7 sp1 home premium 64 bit (also on Microsoft Windows [Version 6.1.760

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Maxim Fomin
On Wednesday, 28 November 2012 at 18:08:59 UTC, Dan wrote: Thanks! I see what you are saying in valgrind. However, the following shows no problem in valgrind. Same code, only using S instead of RefCounted!(int). How could that be explained? Note that both RefCount!() and your posted S have opAs

Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread Ali Çehreli
On 11/28/2012 11:11 AM, 1100110 wrote: > On 11/28/2012 12:57 PM, Dmitry Olshansky wrote: >> 11/28/2012 10:51 PM, Ali Çehreli пишет: >>> A friend of mine reports that the memory usage of the following program >>> grows continuously when compiled with dmd 2.060 and run on Windows 7 sp1 >>> home pr

Re: path matching problem

2012-11-28 Thread jerro
OTOH, I still don't know where "any" is documented. It's clearly some sort of template instantiation, but it doesn't seem to be defined in either std.string or std.object (or anywhere else I've thought to check). And it look as if it would be something very useful to know. It's documented h

Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread 1100110
On 11/28/2012 02:53 PM, Ali Çehreli wrote: On 11/28/2012 11:11 AM, 1100110 wrote: > On 11/28/2012 12:57 PM, Dmitry Olshansky wrote: >> 11/28/2012 10:51 PM, Ali Çehreli пишет: >>> A friend of mine reports that the memory usage of the following program >>> grows continuously when compiled with

Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread Michael
1. Can be solved using allocators http://dlang.org/memory.html#newdelete and http://dlang.org/class.html#ClassAllocator (here deprecated)? 2. Why with class Too { private uint[] pp; this(int s) { pp = new unit[s]; } alias pp this; } Only 3 iterations before out of memory excepti

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Wednesday, 28 November 2012 at 20:30:41 UTC, Maxim Fomin wrote: On Wednesday, 28 November 2012 at 18:08:59 UTC, Dan wrote: This code with version=bug produces garbage because of opAssign. It seems that opAssign is actually called before accessing map: Maxim, thanks for looking more at t

assertion failure with template instantiation of forward reference class

2012-11-28 Thread comco
When trying to compile this code: import std.stdio; class A; class B(T) : T { } void main() { writeln(typeid(B!A)); } I get this error: Assertion failure: '!scope' on line 358 in file 'toobj.c'. Shouldn't it be more like: Error: class main.A unable to resolve forward reference in definit

Re: assertion failure with template instantiation of forward reference class

2012-11-28 Thread bearophile
comco: Looks like a bug? This is what DMD 2.061alpha prints, it doesn't crash: ...\dmd2\src\phobos\std\range.d(603): Error: static assert "Cannot put a string into a LockingTextWriter" ...\dmd2\src\phobos\std\format.d(2349):instantiated from here: put!(LockingTextWriter, string) ..

Re: Is there a portable way to limit memory/cpu usage of a D application?

2012-11-28 Thread Mike Young
On Wednesday, 9 November 2011 at 17:13:14 UTC, Dejan Lekic wrote: Sure nothing prevents me from using setrlimit() in my D app, but perhaps it is something to think about a portable way of doing that. I know I'm over a year late coming in on this conversation, but how would you use setrlimit(

Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread thedeemon
On Wednesday, 28 November 2012 at 22:02:35 UTC, Michael wrote: Only 3 iterations before out of memory exception? Because you used uint instead of ubyte, array is bigger, memory exhausts faster. 3. Why it helps? GC.free(data.ptr); Initial leak happened because for some reason array allocat