Problem with Hiredis Binding

2012-01-05 Thread Puming Zhao
Hi, I'm new in D programming, and does not have much C experience either. After reading TDPL book and playing with some sample codes, I came to decide to try something more `practical`. I began with a Redis client binding from Hiredis C code. Hiredis is a small lib, and seems very simple to bind

Re: Problem with Hiredis Binding

2012-01-05 Thread Timon Gehr
On 01/05/2012 07:14 PM, Joshua Reusch wrote: Am 05.01.2012 17:21, schrieb Puming Zhao: Hi, I'm new in D programming, and does not have much C experience either. After reading TDPL book and playing with some sample codes, I came to decide to try something more `practical`. I began with a Redis

Re: Problem with Hiredis Binding

2012-01-05 Thread Johannes Pfau
Puming Zhao wrote: Hi, I'm new in D programming, and does not have much C experience either. After reading TDPL book and playing with some sample codes, I came to decide to try something more `practical`. I began with a Redis client binding from Hiredis C code. Hiredis is a small lib, and

Re: Problem with Hiredis Binding

2012-01-05 Thread Joshua Reusch
Am 05.01.2012 19:44, schrieb Timon Gehr: On 01/05/2012 07:14 PM, Joshua Reusch wrote: Am 05.01.2012 17:21, schrieb Puming Zhao: Hi, I'm new in D programming, and does not have much C experience either. After reading TDPL book and playing with some sample codes, I came to decide to try

Re: Problem with Hiredis Binding

2012-01-05 Thread Joshua Reusch
Sure ? dlang.org says they are not: http://www.d-programming-language.org/arrays.html#strings Sorry, in the printf section: String literals already have a 0 appended to them, so can be used directly I missed this.

MX records

2012-01-05 Thread Bystroushaak
Hi. Is there any way how to get MX records for given domain? I don't want to implement whole RFC 1034/5. I've looked at std.net.isemail, but it doesn't looks like what I need :/

Re: Problem with Hiredis Binding

2012-01-05 Thread Andrej Mitrovic
Your problem is that you're calling printf on a static char array. If you're going to use printf you have to use it on the .ptr (pointer) field of the static array. Replace this call: printf(Connection error: %s\n, c.errstr); with printf(Connection error: %s\n, c.errstr.ptr); On my end I

Re: Problem with Hiredis Binding

2012-01-05 Thread bearophile
Andrej Mitrovic: I think `long long` in C is 8 bytes, which is the equivalent to D's long type. I think C just requires: sizeof(long long int) = sizeof(long int). For the actual size I think you have to ask to the C compiler. Bye, bearophile

Singleton Pattern

2012-01-05 Thread asm
how can i implementing the singleton pattern in D?

Re: Singleton Pattern

2012-01-05 Thread Andrew Wiley
On Thu, Jan 5, 2012 at 4:15 PM, asm a...@hotmail.com wrote: how can i implementing the singleton pattern in D? Multithreaded or not?

Re: Singleton Pattern

2012-01-05 Thread asm
both if you don't mind

Re: Singleton Pattern

2012-01-05 Thread Ali Çehreli
On 01/05/2012 02:15 PM, asm wrote: how can i implementing the singleton pattern in D? Is singleton still alive? ;) An idea is to instantiate the object in the module's static this(). Ali

Re: Singleton Pattern

2012-01-05 Thread Jonathan M Davis
On Thursday, January 05, 2012 22:15:32 asm wrote: how can i implementing the singleton pattern in D? The same way that you would in C++ or Java, except that unlike you have static constructors that you can use to initialize them, and unlike both, if it's not shared, then it's a singleton per

Re: Problem with Hiredis Binding

2012-01-05 Thread Puming
On Thursday, 5 January 2012 at 22:02:25 UTC, Andrej Mitrovic wrote: Your problem is that you're calling printf on a static char array. If you're going to use printf you have to use it on the .ptr (pointer) field of the static array. Replace this call: printf(Connection error: %s\n,

Re: Problem with Hiredis Binding

2012-01-05 Thread Puming
So you have int integer; in D and long long integer; in C, which doesn't match. I'm not sure what size long long is in C, but I guess you need long in D? Thanks. I've changed `int integer` to `c_long integer` according to this page http://dlang.org/interfaceToC.html c_long is in

Re: Problem with Hiredis Binding

2012-01-05 Thread Mike Parker
On 1/6/2012 11:38 AM, Puming wrote: On Thursday, 5 January 2012 at 22:02:25 UTC, Andrej Mitrovic wrote: Your problem is that you're calling printf on a static char array. If you're going to use printf you have to use it on the .ptr (pointer) field of the static array. Replace this call:

Re: Problem with Hiredis Binding

2012-01-05 Thread Puming
Here is what I've got so far: 1. long long in C is always 64bit, so in D it's long; 2. C's char* string should be converted to!string when used in writeln; 3. String literals in D -IS- zero terminated; And now it's working fine. Thanks everybody :)