Re: Redis client

2012-03-05 Thread Dmitry Olshansky
On 05.03.2012 7:24, Pedro Lacerda wrote: In an attempt to learn D and git I'm building a Redis client. Assertedly there are many problems in the implementation, I'd like to hear opinions pointing them or suggestions. If here isn't the place to ask these type of review, where is?

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Dmitry Olshansky
On 05.03.2012 1:46, Vidar Wahlberg wrote: Coming from a C++/Java world I find D's approach to concurrency slightly difficult to grasp, perhaps someone could help me out a bit on this problem: I'd like to have a method that spawns a new thread which sets up a socket and listens for

Re: abstract base class and class members

2012-03-05 Thread Jesse Phillips
On Sunday, 4 March 2012 at 20:25:40 UTC, Jonathan M Davis wrote: By the way, I wouldn't rely on much that ideone says about D at this point. It's still on version 2.042 of dmd, whereas the latest release is 2.058. - Jonathan M Davis Then ask for the latest version, and as David pointed

Re: Some compile time help..

2012-03-05 Thread Artur Skawina
On 03/04/12 18:14, Andrej Mitrovic wrote: On 3/4/12, Daniel Murphy yebbl...@nospamgmail.com wrote: void f(Args...)(Args args) { foreach(i, T; Args) { static if (isSomeString!T) args[i] = toUTFz(args[i]); } needs_wchar_t(args); } toUTFz returns a pointer, the isSomeString

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Regan Heath
A more efficient approach is to use async socket routines and an event object. So, in main you create a shared event object, then start the listen thread. In listen you call an async select or accept, and then wait on that /and/ the shared event object. To stop listen you set the shared

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Dmitry Olshansky
On 05.03.2012 16:46, Regan Heath wrote: A more efficient approach is to use async socket routines and an event object. So, in main you create a shared event object, then start the listen thread. In listen you call an async select or accept, and then wait on that /and/ the shared event object.

Re: RedBlackTree.lowerBound

2012-03-05 Thread Steven Schveighoffer
On Sun, 19 Feb 2012 16:44:05 -0500, Ellery Newcomer ellery-newco...@utulsa.edu wrote: Is it just me or are lowerBound and upperBound really unintuitively named? It's not just you. Quoting from one of my proposed implementation of std.container.RedBlackTree (I hope Andrei doesn't mind,

Re: IPC: Pipes std.process

2012-03-05 Thread Steven Schveighoffer
On Thu, 23 Feb 2012 08:35:57 -0500, nrgyzer nrgy...@gmail.com wrote: I'm working on IPC's. I already figured out that the implementation depends on the operation system. Is there any solution to support both - windows posix systems? I'm developing on a win-machine and don't want to re-write

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Mon, 27 Feb 2012 16:12:44 -0500, Pedro Lacerda pslace...@gmail.com wrote: Ouch, I just found http://d.puremagic.com/issues/show_bug.cgi?id=3889 So how would I differ from an empty array and a null value? You shouldn't. A null-pointer array is a valid empty array. It can be appended

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Mon, 27 Feb 2012 15:44:40 -0500, Pedro Lacerda pslace...@gmail.com wrote: The expression [] is null evaluates to true here using 2.058, but I expected to be false. What am I missing? The runtime is asked to allocate an empty array. Instead of consuming heap space creating a block with

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Tue, 28 Feb 2012 03:30:01 -0500, Mikael Lindsten mik...@lindsten.net wrote: 2012/2/28 Pedro Lacerda pslace...@gmail.com So are a newly allocated array and a null one just the same thing? int[] a = [], b = null; assert(a == b); assert(a.length == b.length); assert(a.ptr

Re: Regarding std.array.Appender

2012-03-05 Thread Steven Schveighoffer
On Wed, 29 Feb 2012 20:25:35 -0500, bearophile bearophileh...@lycos.com wrote: Do you know why std.array.Appender defines a put method instead of overloading the ~= operator? It should (in addition to put). I see you have already filed an enhancement.

Re: Multiple definition of .../std/regex.d.912_ModuleInfoZ

2012-03-05 Thread André
Am 04.03.2012 16:27, schrieb Dmitry Olshansky: On 04.03.2012 14:49, André wrote: Hi, I have a project compiled as libary and a seccond example project using this library. The library is compiled without errors. As it's a linker error I'd recommend checking that phobos and library are built

Re: Redis client

2012-03-05 Thread Pedro Lacerda
Dmitry, very thanks for the reply! I'm going to make a nice API and acceptance testing using some Redis tutorial. With it working well do you think that worth make project marketing considering the overall code quality? Looking the sources pedantically what's wrong? Pedro Lacerda 2012/3/5

Re: how to use raw sockets

2012-03-05 Thread maarten van damme
hehe, had to make my callback function extern(C). Can circumvent this or do I have to keep using extern(C) callback functions? is there somebody willing to D'ify my bindings? or how should I go about doing that myself?

Re: abstract base class and class members

2012-03-05 Thread Jonathan M Davis
On Monday, March 05, 2012 11:32:39 Jesse Phillips wrote: On Sunday, 4 March 2012 at 20:25:40 UTC, Jonathan M Davis wrote: By the way, I wouldn't rely on much that ideone says about D at this point. It's still on version 2.042 of dmd, whereas the latest release is 2.058. - Jonathan M

D RTTI?

2012-03-05 Thread H. S. Teoh
I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A { string prop1; int prop2; ... void serialize() { __serialize(this); }

Re: D RTTI?

2012-03-05 Thread Justin Whear
On Mon, 05 Mar 2012 12:16:14 -0800, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A { string prop1; int prop2; ... void serialize() {

Re: how to use raw sockets

2012-03-05 Thread maarten van damme
If anyone wants to help with my bindings (maybe they'll ever make it into deimos) You can check them out here: https://github.com/maartenvd/d-libcap-bindings any help/suggestions are welcome.

Re: D RTTI?

2012-03-05 Thread H. S. Teoh
On Mon, Mar 05, 2012 at 08:41:53PM +, Justin Whear wrote: On Mon, 05 Mar 2012 12:16:14 -0800, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A { string prop1; int prop2;

Re: Define .empty property for hashes?

2012-03-05 Thread Steven Schveighoffer
On Fri, 02 Mar 2012 16:21:00 -0500, Ali Çehreli acehr...@yahoo.com wrote: On 03/02/2012 01:08 PM, Andrej Mitrovic wrote: Is there a reason why there's no .empty property for hashes? std.array defines it for arrays, and range types must have it defined. Yes, empty is a part of the

Re: D RTTI?

2012-03-05 Thread Timon Gehr
On 03/05/2012 11:33 PM, H. S. Teoh wrote: On Mon, Mar 05, 2012 at 08:41:53PM +, Justin Whear wrote: On Mon, 05 Mar 2012 12:16:14 -0800, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A {

Re: D RTTI?

2012-03-05 Thread H. S. Teoh
On Tue, Mar 06, 2012 at 12:03:48AM +0100, Timon Gehr wrote: On 03/05/2012 11:33 PM, H. S. Teoh wrote: [...] Is there a way to tell whether or not a given class is a derived class or not? I'm using the Serializable template to insert serialize() into the class, and for derived classes I need to

Re: D RTTI?

2012-03-05 Thread H. S. Teoh
On Mon, Mar 05, 2012 at 03:26:01PM -0800, H. S. Teoh wrote: [...] template Serializable() { enum Serializable = q{ static if (__traits(hasMember, typeof(this), serializable)) [...] Ugh, that last string should

duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Zach the Mystic
I'm not sure if the linker errors I'm getting are my fault or D's. I'm trying to do incremental compilation since the size of my program is starting to break my computer, slowing compilations down by four or five times. Suppose I have two libraries: lib1.a lib2.a I build lib1 with a bunch of

Translate for chars to strings

2012-03-05 Thread Andrej Mitrovic
There's a really useful function 'translate' in std.string, used like this: __gshared dchar[dchar] MangleTable; shared static this() { MangleTable = [ '*':'p', // ptr '':'r', // reference '':'L', // left angle '':'R', // right angle ' ':'_',

Re: Translate for chars to strings

2012-03-05 Thread Ali Çehreli
On 03/05/2012 04:32 PM, Andrej Mitrovic wrote: There's a really useful function 'translate' in std.string, used like this: __gshared dchar[dchar] MangleTable; shared static this() { MangleTable = [ '*':'p', // ptr '':'r', // reference '':'L', // left

How to check type of an object to a class name?

2012-03-05 Thread Chris Pons
Is it possible to check the type of an object to a class name? //Something like this: Class test { //... } assert(is(anonObject == typeof(test))

Re: D RTTI?

2012-03-05 Thread Artur Skawina
On 03/05/12 21:16, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A { string prop1; int prop2; ... void serialize() {

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Zach the Mystic
Reading the documentation about compiler options and flags here: http://dlang.org/dmd-osx.html led me to believe that building libraries was the right way to do incremental compilation. But I thought, well, can I just build file1.o object files instead? So I've started doing that and I've

Re: Is empty array null?

2012-03-05 Thread bearophile
Steven Schveighoffer: D makes arrays as safe as possible, and as useful as possible. The pointer value itself is an implementation detail, and should rarely be used to determine logic. D array design also leads to some traps, like forgetting to use ref here: void append5andMore(int[] a)

Re: D RTTI?

2012-03-05 Thread H. S. Teoh
On Tue, Mar 06, 2012 at 01:51:51AM +0100, Artur Skawina wrote: On 03/05/12 21:16, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A { string prop1; int prop2; ...

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Mon, 05 Mar 2012 20:00:12 -0500, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: D makes arrays as safe as possible, and as useful as possible. The pointer value itself is an implementation detail, and should rarely be used to determine logic. D array design also

Re: How to check type of an object to a class name?

2012-03-05 Thread Jonathan M Davis
On Tuesday, March 06, 2012 01:37:05 Chris Pons wrote: Is it possible to check the type of an object to a class name? //Something like this: Class test { //... } assert(is(anonObject == typeof(test)) If you want to check whether a particular object is of a particular type at runtime,

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Jonathan M Davis
On Tuesday, March 06, 2012 01:53:02 Zach the Mystic wrote: Reading the documentation about compiler options and flags here: http://dlang.org/dmd-osx.html led me to believe that building libraries was the right way to do incremental compilation. But I thought, well, can I just build file1.o

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Zach the Mystic
Libraries are not intented for incremental compilation. They are for distributing code in a unit which can be used by programs. And in the case of a shared library, it gives the added benefit of reducing the amount of duplicate code you get in binaries (saving both memory and disk space). If

How do I force something onto the heap? (need for libev)

2012-03-05 Thread Tyler Jameson Little
I've been playing with libev in D lately, and I've run into a problem. I've been able to hack around it, but it'd like to find a better, more general solution. Here's a link to the code: https://github.com/beatgammit/fun-with-d/blob/master/libev/tcp_server.d The code is a basic TCP server that

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Jonathan M Davis
On Tuesday, March 06, 2012 05:26:34 Zach the Mystic wrote: Libraries are not intented for incremental compilation. They are for distributing code in a unit which can be used by programs. And in the case of a shared library, it gives the added benefit of reducing the amount of

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Mike Parker
On 3/6/2012 1:34 PM, Tyler Jameson Little wrote: I've been playing with libev in D lately, and I've run into a problem. I've been able to hack around it, but it'd like to find a better, more general solution. Here's a link to the code:

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Mike Parker
On 3/6/2012 1:55 PM, Mike Parker wrote: On 3/6/2012 1:34 PM, Tyler Jameson Little wrote: I've been playing with libev in D lately, and I've run into a problem. I've been able to hack around it, but it'd like to find a better, more general solution. Here's a link to the code:

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Tyler Jameson Little
On Tuesday, 6 March 2012 at 04:54:44 UTC, Mike Parker wrote: On 3/6/2012 1:34 PM, Tyler Jameson Little wrote: I've been playing with libev in D lately, and I've run into a problem. I've been able to hack around it, but it'd like to find a better, more general solution. Here's a link to the

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Tyler Jameson Little
Oh, thanks! I missed your reply. That sounds reasonable, and a lot better than my super hacky Socket[]. Thanks!

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Mike Parker
On 3/6/2012 2:01 PM, Mike Parker wrote: On 3/6/2012 1:55 PM, Mike Parker wrote: On 3/6/2012 1:34 PM, Tyler Jameson Little wrote: I've been playing with libev in D lately, and I've run into a problem. I've been able to hack around it, but it'd like to find a better, more general solution.

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Mike Parker
On 3/6/2012 2:10 PM, Tyler Jameson Little wrote: Oh, thanks! I missed your reply. That sounds reasonable, and a lot better than my super hacky Socket[]. Thanks! I've never used libev and am only vaguely familiar with it. But if the callbacks are called from outside the main thread, you'll

Re: How do I force something onto the heap? (need for libev)

2012-03-05 Thread Tyler Jameson Little
On Tuesday, 6 March 2012 at 05:17:20 UTC, Mike Parker wrote: On 3/6/2012 2:10 PM, Tyler Jameson Little wrote: Oh, thanks! I missed your reply. That sounds reasonable, and a lot better than my super hacky Socket[]. Thanks! I've never used libev and am only vaguely familiar with it. But if

Re: D RTTI?

2012-03-05 Thread Jacob Carlborg
On 2012-03-05 21:16, H. S. Teoh wrote: I know D doesn't really have RTTI yet, but I'm experimenting with faking it by doing something like: class A { string prop1; int prop2; ... void serialize() {

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Jacob Carlborg
On 2012-03-06 02:21, Jonathan M Davis wrote: On Tuesday, March 06, 2012 01:53:02 Zach the Mystic wrote: Reading the documentation about compiler options and flags here: http://dlang.org/dmd-osx.html led me to believe that building libraries was the right way to do incremental compilation. But

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Jacob Carlborg
On 2012-03-06 01:04, Zach the Mystic wrote: I'm not sure if the linker errors I'm getting are my fault or D's. I'm trying to do incremental compilation since the size of my program is starting to break my computer, slowing compilations down by four or five times. I just want to give you a

Re: duplicate symbol linker errors, my fault or D's?

2012-03-05 Thread Jonathan M Davis
On Tuesday, March 06, 2012 08:29:53 Jacob Carlborg wrote: On 2012-03-06 02:21, Jonathan M Davis wrote: On Tuesday, March 06, 2012 01:53:02 Zach the Mystic wrote: Reading the documentation about compiler options and flags here: http://dlang.org/dmd-osx.html led me to believe that