Re: Input timeout

2013-05-13 Thread Ali Çehreli
On 05/13/2013 09:22 PM, Josh wrote: > Your answer requires the user to > press enter to send the line. Would it be possible to have getch-like > behaviour without using C, or would that be the only way? I don't know how to set stdin to non-blocking mode in D. However, if you are sure that stdin

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timothee Cour
> __ctor is a 'this' call, it needs a this (BTW, I get different errors than > you): Seems like not (see my corrected bug in previous post) > Not sure how you would do that in one line ditto >> Why not use 'this' instead of '__ctor', and make it documented (and >> reliable, ie work in the above

Re: What sync object should i use?

2013-05-13 Thread Heinz
BTW, given recent discussion on memory barriers, I think my previous statement that the mutex does not need to be locked to call notify is probably incorrect. Haven't had any issues calling notify outside a synchronized statement, even from multiple threads. At least this works under Win32 wi

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timothee Cour
> I declared fun(T) as fun(T)() with the added parenthesis, and it > worked (tested on dmd 2.062 / ubuntu 64bits). sorry I reduced wrongly. Here's the inconsistency: struct A { this(T)(T x) { } } auto fun1(){ auto a=A.__ctor!(int)(1); //OK return a; } auto fun2()

Re: Input timeout

2013-05-13 Thread Josh
On Tuesday, 14 May 2013 at 04:14:27 UTC, Ali Çehreli wrote: On 05/13/2013 08:50 PM, Josh wrote: Is there a way in D to only accept input for a certain time, instead of std.stdio.readln's behaviour? Something like "Press a key in 3 seconds to abort". Thanks Josh An unlikely solution is std.

Re: Input timeout

2013-05-13 Thread Ali Çehreli
On 05/13/2013 08:50 PM, Josh wrote: Is there a way in D to only accept input for a certain time, instead of std.stdio.readln's behaviour? Something like "Press a key in 3 seconds to abort". Thanks Josh An unlikely solution is std.concurrency because it already has a timeout facility: impor

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Juan Manuel Cabo
On Tuesday, 14 May 2013 at 03:34:52 UTC, Timothee Cour wrote: A) The behavior of __ctor (whether or not documented) seems broken / unreliable: struct A{this(T)(T x){}} void fun(T){ auto a=A.__ctor!(int)(1); } void main(){ auto a=A.__ctor!(int)(1); //ok fun!int(); //Error: type A is not

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Steven Schveighoffer
On Mon, 13 May 2013 23:34:39 -0400, Timothee Cour wrote: A) The behavior of __ctor (whether or not documented) seems broken / unreliable: struct A{this(T)(T x){}} void fun(T){ auto a=A.__ctor!(int)(1); } void main(){ auto a=A.__ctor!(int)(1); //ok fun!int(); //Error: type A is not

Input timeout

2013-05-13 Thread Josh
Is there a way in D to only accept input for a certain time, instead of std.stdio.readln's behaviour? Something like "Press a key in 3 seconds to abort". Thanks Josh

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timothee Cour
A) The behavior of __ctor (whether or not documented) seems broken / unreliable: struct A{this(T)(T x){}} void fun(T){ auto a=A.__ctor!(int)(1); } void main(){ auto a=A.__ctor!(int)(1); //ok fun!int(); //Error: type A is not an expression } Is that a bug? B) Why not use 'this' instead of

Re: how to avoid memory leaking

2013-05-13 Thread Adam D. Ruppe
On Monday, 13 May 2013 at 21:28:34 UTC, maarten van damme wrote: Adam checks this thread so he'll probably read the errors about simpledisplay. if not I'll copy paste and put in a bug report on github. I won't be on my linux box with free time until at least tomorrow afternoon but i'll check

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timon Gehr
On 05/13/2013 10:27 PM, Timothee Cour wrote: While writing DIP40, I came upon the following question: how to instantiate explicitly template parameters for both the class/struct AND the constructor? for example: struct A(T1){this(T2)(){...}} ? (T2 could be used somehow inside the ctor body for e

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timon Gehr
On 05/14/2013 01:25 AM, Timon Gehr wrote: On 05/13/2013 10:27 PM, Timothee Cour wrote: While writing DIP40, I came upon the following question: how to instantiate explicitly template parameters for both the class/struct AND the constructor? for example: struct A(T1){this(T2)(){...}} ? (T2 could

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Steven Schveighoffer
On Mon, 13 May 2013 19:04:39 -0400, Timothee Cour wrote: Thanks! should that be considered as a limitation, and therefore be fixed? (for example by documenting the __ctor syntax)? The static make trick is boilerplate and shouldn't be considered the best way. Well, it's not really boilerpl

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timothee Cour
Thanks! should that be considered as a limitation, and therefore be fixed? (for example by documenting the __ctor syntax)? The static make trick is boilerplate and shouldn't be considered the best way. On Mon, May 13, 2013 at 3:06 PM, Steven Schveighoffer wrote: > On Mon, 13 May 2013 16:27:44 -04

Re: What sync object should i use?

2013-05-13 Thread Juan Manuel Cabo
On Monday, 13 May 2013 at 21:55:45 UTC, Steven Schveighoffer wrote: On Mon, 13 May 2013 17:04:22 -0400, Juan Manuel Cabo wrote: I seem to recall (though I might be wrong) that win32 events can be signalled before the thread calls WaitForSingleObject (or WaitForMultipleObjects), and if it was

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Steven Schveighoffer
On Mon, 13 May 2013 16:27:44 -0400, Timothee Cour wrote: While writing DIP40, I came upon the following question: how to instantiate explicitly template parameters for both the class/struct AND the constructor? for example: struct A(T1){this(T2)(){...}} ? (T2 could be used somehow inside the

Re: What sync object should i use?

2013-05-13 Thread Steven Schveighoffer
On Mon, 13 May 2013 17:04:22 -0400, Juan Manuel Cabo wrote: I seem to recall (though I might be wrong) that win32 events can be signalled before the thread calls WaitForSingleObject (or WaitForMultipleObjects), and if it was signalled, the call returns immediately. I think this was very

Re: What sync object should i use?

2013-05-13 Thread Steven Schveighoffer
On Mon, 13 May 2013 16:44:36 -0400, Heinz wrote: 3) Need a working example in D? (by Steven Schveighoffer): http://forum.dlang.org/thread/j7sdte$25qm$1...@digitalmars.com Well, whaddya know. Glad my former self could help :) BTW, given recent discussion on memory barriers, I think my previ

Re: how to avoid memory leaking

2013-05-13 Thread maarten van damme
I'll check every uint occurance, thank you. I'm on windows so I won't get the "maximum number of clients" error you talk about. The loop I used inside main was : "while(true){ curtrans=generateTransformationMatrix(); for(int y=0;y > On Friday, 10 May 2013 at 23:18:31 UTC, maarten van damme wrote:

Re: What sync object should i use?

2013-05-13 Thread Juan Manuel Cabo
On Monday, 13 May 2013 at 20:44:37 UTC, Heinz wrote: Ok, here's a summary in case someone else is in the same need: 1) Want to know what "mutex/condition" are, how do they work and when to use them? Here's a good resource: http://stackoverflow.com/a/4742236 2) If you come to the question "Wh

Re: Notifications on D documentation updates

2013-05-13 Thread Ali Çehreli
On 05/13/2013 01:10 PM, ric wrote: Is there a way to know if any D documentation was updated or a new D article is added in the D site? I wanted to keep my references in sync with updates in the documentation. Maybe, RSS or something? The web site development is on github as well. Go to the pro

Re: how to avoid memory leaking

2013-05-13 Thread Maxim Fomin
On Friday, 10 May 2013 at 23:18:31 UTC, maarten van damme wrote: I'm trying to generate images and after displaying them I want to save them to a png file. I use parallelism to generate them asynchronously with the gui-thread to avoid blocking (don't know if this is really relevant). If I add

Re: What sync object should i use?

2013-05-13 Thread Heinz
Ok, here's a summary in case someone else is in the same need: 1) Want to know what "mutex/condition" are, how do they work and when to use them? Here's a good resource: http://stackoverflow.com/a/4742236 2) If you come to the question "Why a condition needs a mutex?": http://stackoverflow.c

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Jonathan M Davis
On Monday, May 13, 2013 13:27:44 Timothee Cour wrote: > While writing DIP40, I came upon the following question: > how to instantiate explicitly template parameters for both the > class/struct AND the constructor? > for example: struct A(T1){this(T2)(){...}} ? (T2 could be used > somehow inside the

how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Timothee Cour
While writing DIP40, I came upon the following question: how to instantiate explicitly template parameters for both the class/struct AND the constructor? for example: struct A(T1){this(T2)(){...}} ? (T2 could be used somehow inside the ctor body for example) // auto a=A!double!int(); // CT error T

Notifications on D documentation updates

2013-05-13 Thread ric
Is there a way to know if any D documentation was updated or a new D article is added in the D site? I wanted to keep my references in sync with updates in the documentation. Maybe, RSS or something?

Re: What sync object should i use?

2013-05-13 Thread Heinz
On Monday, 13 May 2013 at 19:41:48 UTC, Heinz wrote: Hi, I'm looking for an object in "core.sync" whose internal counter can be 0 or 1 (signaled/not signaled), just like Event Objects in Win32 (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682396%28v=vs.85%29.aspx). The object mu

Re: What sync object should i use?

2013-05-13 Thread Heinz
On Monday, 13 May 2013 at 19:49:51 UTC, Steven Schveighoffer wrote: On Mon, 13 May 2013 15:41:47 -0400, Heinz wrote: Hi, I'm looking for an object in "core.sync" whose internal counter can be 0 or 1 (signaled/not signaled), just like Event Objects in Win32 (http://msdn.microsoft.com/en-us

Re: What sync object should i use?

2013-05-13 Thread Steven Schveighoffer
On Mon, 13 May 2013 15:41:47 -0400, Heinz wrote: Hi, I'm looking for an object in "core.sync" whose internal counter can be 0 or 1 (signaled/not signaled), just like Event Objects in Win32 (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682396%28v=vs.85%29.aspx). The object mu

What sync object should i use?

2013-05-13 Thread Heinz
Hi, I'm looking for an object in "core.sync" whose internal counter can be 0 or 1 (signaled/not signaled), just like Event Objects in Win32 (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682396%28v=vs.85%29.aspx). The object must be waitable and able to notify waiters. A semaphor

Re: Interface vs pure abstract class - speed.

2013-05-13 Thread Sean Cavanaugh
On 5/12/2013 12:31 PM, SundayMorningRunner wrote: Hello, let's say I have the choice between using an abstract class or an interface to declare a "plan", a "template" for the descendants. From the dmd compiler point of view, should I use the abstract class version (so I guess that for each meth

Re: Disgusted

2013-05-13 Thread maarten van damme
If you define intelligence as the ability to learn computer languages, I'd have to disagree with you. No reason to be disgusted, just curious. Why on earth would you spend your time doing that? 2013/5/13 D-Ratiseur > On Monday, 13 May 2013 at 00:21:06 UTC, John Colvin wrote: > >> On Monday, 13

Re: Red-Black tree with customized sorting

2013-05-13 Thread Ivan Kazmenko
On Monday, 13 May 2013 at 15:26:12 UTC, Steven Schveighoffer wrote: On Sun, 12 May 2013 17:09:56 -0400, Paolo Bolzoni wrote: What is wrong? How I am supposed to pass less address to do the comparison? I think it is this issue: http://d.puremagic.com/issues/show_bug.cgi?id=9513 I am going

Re: Red-Black tree with customized sorting

2013-05-13 Thread Steven Schveighoffer
On Sun, 12 May 2013 17:09:56 -0400, Paolo Bolzoni wrote: What is wrong? How I am supposed to pass less address to do the comparison? I think it is this issue: http://d.puremagic.com/issues/show_bug.cgi?id=9513 I am going to fix this, soon. -Steve

Re: how to avoid memory leaking

2013-05-13 Thread Adam D. Ruppe
actually the output array doesn't need to be there at all, I could compress on the fly, adding the filter byte to a much smaller buffer, then writing straight out to the file. Then the only big array would be the one in the image class itself, which is easy to manage. In fact, I did another f

Re: how to avoid memory leaking

2013-05-13 Thread Adam D. Ruppe
On Monday, 13 May 2013 at 07:13:03 UTC, maarten van damme wrote: But seeing as the memory only starts growing when I put the png line in This is pretty strange because looking at the source there, the only time data is even referenced is here: output ~= data[pos..pos+bytesPer

Re: Structure's inheritance

2013-05-13 Thread Dicebot
I believe template mixin are the way to go for structs. Small annotated example: // http://dpaste.1azy.net/56dd2513 mixin template Operators() { // Verify "a" field exists for better compile-time error. Hard-coded here. // As an alternative, name of field to use can be provided as a templat

Re: how to avoid memory leaking

2013-05-13 Thread maarten van damme
But seeing as the memory only starts growing when I put the png line in, and that I keep deleting the old class and replacing it for a new instance, shouldn't the gc clean up everything as nothing can still be referencing to that data? I am working on windows, on linux my original code segfaulted,