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 belie

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 warn

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 I

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: 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: 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 li

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. Here's

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 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 cod

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: https://github.com/

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: https://github.com/beatgammit/fun-with-d/blob/master/libev/t

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 o

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

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

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 > fil

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 ru

Re: D RTTI?

2012-03-05 Thread Kenji Hara
On Monday, 5 March 2012 at 22:31:58 UTC, H. S. Teoh wrote: OK, it's a bit ugly I supopse, but I can live with that. 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

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Mon, 05 Mar 2012 20:00:12 -0500, bearophile 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 leads to some traps, like for

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 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[

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 got

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: How to check type of an object to a class name?

2012-03-05 Thread Pedro Lacerda
This works: assert(typeid(anonObject) == typeid(test)); Pedro Lacerda 2012/3/5 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)) >

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: 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 an

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 ' ':'_',

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 fi

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 shoul

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 n

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: Define .empty property for hashes?

2012-03-05 Thread Steven Schveighoffer
On Fri, 02 Mar 2012 16:21:00 -0500, Ali Çehreli 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 InputRange interface. Slic

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; > >

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 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() { >

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: 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. > > > > -

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: 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 Dmi

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 us

Re: Regarding std.array.Appender

2012-03-05 Thread Steven Schveighoffer
On Wed, 29 Feb 2012 20:25:35 -0500, bearophile 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. http://d.puremagic.com/issues/show_bug.cgi?id=4287 -S

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Tue, 28 Feb 2012 03:30:01 -0500, Mikael Lindsten wrote: 2012/2/28 Pedro Lacerda 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 == a.ptr); Hi all, Sorry if this is

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Mon, 27 Feb 2012 15:44:40 -0500, Pedro Lacerda 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 no data in it, it

Re: Is empty array null?

2012-03-05 Thread Steven Schveighoffer
On Mon, 27 Feb 2012 16:12:44 -0500, Pedro Lacerda 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 to, passed around, w

Re: IPC: Pipes & std.process

2012-03-05 Thread Steven Schveighoffer
On Thu, 23 Feb 2012 08:35:57 -0500, nrgyzer 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 my app on lin

Re: RedBlackTree.lowerBound

2012-03-05 Thread Steven Schveighoffer
On Sun, 19 Feb 2012 16:44:05 -0500, Ellery Newcomer 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, but I have included his re

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. T

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 eve

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 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 checks if a

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 out,

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 connections

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? github.com/pslace