String representation of enum value

2013-08-04 Thread Marek Janukowicz
Given following code: enum ErrorCode { BAD_REQUEST, UNKNOWN } ErrorCode code; is there any way to get string representation of code with regard to values defined in enum? I mean - if code == 0, I'd like to get a string "BAD_REQUEST", if it's == 1, I'd like to get string a "UNKNOWN". Of cou

Re: String representation of enum value

2013-08-04 Thread Robik
On Sunday, 4 August 2013 at 13:57:20 UTC, Marek Janukowicz wrote: Given following code: enum ErrorCode { BAD_REQUEST, UNKNOWN } ErrorCode code; is there any way to get string representation of code with regard to values defined in enum? I mean - if code == 0, I'd like to get a string "BA

Re: String representation of enum value

2013-08-04 Thread Marek Janukowicz
Robik wrote: > I think std.conv.to!string is what are you looking for :) > > http://dpaste.dzfl.pl/e1c38f8f Wow, so simple, thanks -- Marek Janukowicz

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-04 Thread Ali Çehreli
On 08/03/2013 09:05 AM, monarch_dodra wrote: > On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote: >> On 08/03/2013 07:58 AM, bearophile wrote: >> >> > Gabi: >> > >> >> //HOW TO pass F1(..) the args we were called with ? >> > >> > >> > import std.stdio; >> > >> > void f1(Args...)(Arg

Re: Socket.select interrupted system call because of GC

2013-08-04 Thread Marek Janukowicz
David Nadlinger wrote: > See > https://github.com/apache/thrift/blob/master/lib/d/src/thrift/server/transport/socket.d#L144 > for a production-tested implementation. When I wrote that code, > it wasn't possible to do this in a platform-independent way using > std.socket (see > https://github.com/

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-04 Thread monarch_dodra
On Sunday, 4 August 2013 at 15:29:48 UTC, Ali Çehreli wrote: On 08/03/2013 09:05 AM, monarch_dodra wrote: > On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote: >> On 08/03/2013 07:58 AM, bearophile wrote: >> >> > Gabi: >> > >> >> //HOW TO pass F1(..) the args we were called with ? >

Is this a good pattern for allocation?

2013-08-04 Thread JS
Trying to avoid GC dependence on my objects. interface Alloc(T) { T New(A...)(A args); //final T Factory(A...)(T, A args) { return new T(args); } } class A(T) : Alloc!(A!(T)) { static A!T New() { return new A!T();// Use GC for now // Factor(A