Re: char* to long

2012-01-25 Thread Mars
Thanks for the replies, everyone.I guess I'll go with the double conversion for now.

Singleton question (shared class)

2012-01-25 Thread Mars
Hello everybody. I have a few classes which I want to implement as singletons (like configuration, database connection, etc.), because I have to access them throughout my whole program, and from different threads. I'm implementing the singletons like this:

Re: Singleton question (shared class)

2012-01-25 Thread Mars
Alternative approach, I just found: http://pastie.org/private/1jlcvfostnbopfp3quflg If I get that right, this is basically the classic singleton, like it would be in other languages, right? So... what's the best way? Mars

Re: Singleton question (shared class)

2012-01-25 Thread Steven Schveighoffer
On Wed, 25 Jan 2012 09:50:57 -0500, Mars -@-.- wrote: Alternative approach, I just found: http://pastie.org/private/1jlcvfostnbopfp3quflg If I get that right, this is basically the classic singleton, like it would be in other languages, right? So... what's the best way? This is an ok

Re: Invalid bounding interval [, ]

2012-01-25 Thread Timon Gehr
On 01/25/2012 12:28 PM, C wrote: auto chunk = new ubyte[1024]; foreach(ref x; chunk) x = uniform![](ubyte.min, ubyte.max); Thank you all for your replies. @ Timon, I have two questions: 1) How come you can omit parentheses for uniform's parameter, shouldn't it be uniform!([])(...) ? If

Re: actors library?

2012-01-25 Thread xancorreu
Thanks Gehr for your examples. Very illustrative. I wanted what you do in example 1 like a library. It's easy import actors library than to define your own actors (class). Thanks, Xan. Al 24/01/12 21:11, En/na Timon Gehr ha escrit: On 01/24/2012 07:51 PM, xancorreu wrote: Al 24/01/12 13:37,

Re: Meaning of const

2012-01-25 Thread H. S. Teoh
On Tue, Jan 24, 2012 at 08:01:41PM -0500, bearophile wrote: Jonathan M Davis: Now, the confusing part is the fact that unlike C++, D allows you to put the const for making the function on the _left-hand_ side of the function (C++ only lets you put it on the right). This is to

Re: KeyType, ValueType traits for hashes

2012-01-25 Thread Jonathan M Davis
On Wednesday, January 25, 2012 01:24:59 Andrej Mitrovic wrote: Unfortunately you would have to do that with every template in order to be consistent, and that's too much work. The real improvement would be for the compiler to let us know *which* of the constraints failed, e.g.: alias

Re: Meaning of const

2012-01-25 Thread Jonathan M Davis
On Tuesday, January 24, 2012 16:24:27 Ali Çehreli wrote: On 01/24/2012 04:06 PM, Jonathan M Davis wrote: class A { int x; const int f1() { ... } int f2() const { ... } const(int) f3() { ... } } [...] int f2() const becomes int f2(const A this)

Re: Calling a C++ Object from D

2012-01-25 Thread David Eagen
On Tue, 24 Jan 2012 07:22:46 -0600, Richard Webb we...@beardmouse.org.uk wrote: How about something like this (using Juno): /// import juno.com.core, std.stdio; abstract final class SystemInformation { mixin(uuid(C01B9BA0-BEA7-41BA-B604-D0A36F469133)); mixin

Re: Invalid bounding interval [, ]

2012-01-25 Thread bearophile
C: I want to fill a ubyte array with random data. In D ubytes are not char, they are two different types. So if you want ubytes, then use ubytes: uniform!([])(ubyte.min, ubyte.max) Regarding your error, a reduced test case: import std.random: uniform; void main() {

Re: Invalid bounding interval [, ]

2012-01-25 Thread Timon Gehr
On 01/25/2012 04:50 AM, bearophile wrote: C: I want to fill a ubyte array with random data. In D ubytes are not char, they are two different types. So if you want ubytes, then use ubytes: uniform!([])(ubyte.min, ubyte.max) Regarding your error, a reduced test case: import std.random:

Re: Invalid bounding interval [, ]

2012-01-25 Thread Timon Gehr
On 01/25/2012 04:25 AM, C wrote: I want to fill a ubyte array with random data. The code compiles with no warnings or errors. Source snippet: auto prng = Random(unpredictableSeed); ubyte[] chunk; chunk.length = 1024; fill(chunk, uniform!([])('\x00',

Re: Invalid bounding interval [, ]

2012-01-25 Thread Era Scarecrow
1) How come you can omit parentheses for uniform's parameter, shouldn't it be uniform!([])(...) ? I think I can answer this. With ! already being used, it already knows it's a template and is separating your argument. Being as you only have 1 argument, it's allowed. That's why you can

immutable bug?

2012-01-25 Thread Era Scarecrow
DMD 2.057 - Windows version I'm in the middle of converting a medium sized project from C to D. While I'm doing that I have several static data structures. Here's where I find myself. Can't probably duplicate the error message without the full sources. Since immutable is transitive, this

A bug due to negating object.sizeof

2012-01-25 Thread Ali Çehreli
There has been two threads about signed/unsigned recently on the main D forum, especially on the size_t and sizediff_t aliases. This is not directly related to those aliases but here is a fresh bug of mine. The following code attempts to point at the ID3v1 block from the end of an mp3 file:

Re: eof of socketstream?

2012-01-25 Thread useo6
Nobody knows how to solve that problem? I tried some other solutions where I ran into the same problem: /* Works as long as bytes available and the length of my buffer is 1 - doesn't work if the file-size (which is unknown) has a size which is a multiple of the buffer size... for ex. if the

Re: immutable bug?

2012-01-25 Thread Steven Schveighoffer
On Wed, 25 Jan 2012 10:46:57 -0500, Era Scarecrow rtcv...@yahoo.com wrote: DMD 2.057 - Windows version I'm in the middle of converting a medium sized project from C to D. While I'm doing that I have several static data structures. Here's where I find myself. Can't probably duplicate

Re: immutable bug?

2012-01-25 Thread Era Scarecrow
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article //immutable should (i think) implicitly change char[] to immutable(char[]) Your issue is here, (I'm guessing). If do this (after slimming down to a compilable sample): alias immutable(NotePart) NP; then it compiles.

Re: Definition of extern(System)?

2012-01-25 Thread Mike Wey
On 01/25/2012 05:39 AM, Jonathan M Davis wrote: As http://d.puremagic.com/issues/show_bug.cgi?id=4788 points out, extern(System) isn't properly documented, so I have no idea what it translates to. Does anyone know what exactly it translates to on Linux/Posix and Windows? - Jonathan M Davis

Re: Definition of extern(System)?

2012-01-25 Thread Trass3r
I was pretty sure it's somewhere in the spec.

Re: Meaning of const

2012-01-25 Thread Timon Gehr
On 01/25/2012 02:29 AM, H. S. Teoh wrote: On Tue, Jan 24, 2012 at 08:01:41PM -0500, bearophile wrote: Jonathan M Davis: Now, the confusing part is the fact that unlike C++, D allows you to put the const for making the function on the _left-hand_ side of the function (C++ only lets you put it

Re: Meaning of const

2012-01-25 Thread H. S. Teoh
On Wed, Jan 25, 2012 at 11:50:57PM +0100, Timon Gehr wrote: On 01/25/2012 02:29 AM, H. S. Teoh wrote: [...] But since Walter doesn't like the idea of restricting the syntax to 'int y() const', then what about making it mandatory to write: const(int) x; instead of: const int

Re: Definition of extern(System)?

2012-01-25 Thread Jonathan M Davis
On Wednesday, January 25, 2012 22:31:19 Mike Wey wrote: On 01/25/2012 05:39 AM, Jonathan M Davis wrote: As http://d.puremagic.com/issues/show_bug.cgi?id=4788 points out, extern(System) isn't properly documented, so I have no idea what it translates to. Does anyone know what exactly it

Re: Definition of extern(System)?

2012-01-25 Thread Jonathan M Davis
On Wednesday, January 25, 2012 23:18:04 Trass3r wrote: I was pretty sure it's somewhere in the spec. I can't find it searching for it or grepping for it. - Jonathan M Davis

Re: Singleton question (shared class)

2012-01-25 Thread Andrew Wiley
On Wed, Jan 25, 2012 at 9:35 AM, Steven Schveighoffer schvei...@yahoo.com wrote: On Wed, 25 Jan 2012 09:50:57 -0500, Mars -@-.- wrote: Alternative approach, I just found: http://pastie.org/private/1jlcvfostnbopfp3quflg If I get that right, this is basically the classic singleton, like it

Re: Meaning of const

2012-01-25 Thread Timon Gehr
On 01/26/2012 12:35 AM, H. S. Teoh wrote: On Wed, Jan 25, 2012 at 11:50:57PM +0100, Timon Gehr wrote: On 01/25/2012 02:29 AM, H. S. Teoh wrote: [...] But since Walter doesn't like the idea of restricting the syntax to 'int y() const', then what about making it mandatory to write:

Re: Definition of extern(System)?

2012-01-25 Thread Daniel Murphy
Jonathan M Davis jmdavisp...@gmx.com wrote in message news:mailman.11.1327521278.25230.digitalmars-d-le...@puremagic.com... As http://d.puremagic.com/issues/show_bug.cgi?id=4788 points out, extern(System) isn't properly documented, so I have no idea what it translates to. Does anyone know

inout constructor?

2012-01-25 Thread bearophile
In this bug report I've seen an inout struct constructor: http://d.puremagic.com/issues/show_bug.cgi?id=7369 struct TestStruct { this(int data) inout {} } Do you know what's the usage of this? Bye and thank you, bearophile