Re: throwing a RangeError in non-release mode

2010-07-02 Thread Simen kjaeraas
Steven Schveighoffer wrote: When not in release mode, accessing an out-of-bounds element in an array throws a RangeError. I would like to do the same thing in dcollections when indexing, but the only tool I know of that enables throwing an error in non-release mode is assert, and that onl

throwing a RangeError in non-release mode

2010-07-02 Thread Steven Schveighoffer
When not in release mode, accessing an out-of-bounds element in an array throws a RangeError. I would like to do the same thing in dcollections when indexing, but the only tool I know of that enables throwing an error in non-release mode is assert, and that only throws an assert error. Doe

Re: Storing "auto" types in classes

2010-07-02 Thread BCS
Hello Jonathan, On Friday, July 02, 2010 09:46:37 Rob Adelberg wrote: I'm sure this has come up before, but I want to store something like an std.array appender in a class. All of the examples use auto for the type but you can't put that in a class definition, so what do you put? Example: cl

Re: Is the memory address of classinfo the same for all instances of a class?

2010-07-02 Thread Simen kjaeraas
Heywood Floyd wrote: I noted that the classinfo.name-strings typically looks like this: classtype.Foo classtype.Bar classtype.Cat classtype.Dog Doesn't this first "classtype."-part introduce overhead when these strings are used as keys in an AA? The string co

Re: dcollections ArrayList pb with mixin template

2010-07-02 Thread BLS
On 02/07/2010 00:47, bearophile wrote: BLS: I don't understand (in this context) . Can you please elaborate a bit more ? I have not shown you code because I don't understand your context. But you can put inside static this() {...} code that can't be run statically, like the initialization of

MS VirtualFree(), VirtualAlloc()

2010-07-02 Thread BLS
Hi, for reasons I don't completely understand I would like to implement a BIP Buffer in D2. ;) well async IO is the use case .. I think. How can I allocate/free buffer-space from virtual memory ? What I am looking for is a way to do platform independent allocating of memory from the virtual a

Re: Storing "auto" types in classes

2010-07-02 Thread Jonathan M Davis
On Friday, July 02, 2010 09:46:37 Rob Adelberg wrote: > I'm sure this has come up before, but I want to store something like an > std.array appender in a class. All of the examples use auto for the type > but you can't put that in a class definition, so what do you put? > > Example: > class packe

Storing "auto" types in classes

2010-07-02 Thread Rob Adelberg
I'm sure this has come up before, but I want to store something like an std.array appender in a class. All of the examples use auto for the type but you can't put that in a class definition, so what do you put? Example: class packet{...} class A { packet [] packetlist; appender!(packet)

Re: Is the memory address of classinfo the same for all instances of a class?

2010-07-02 Thread Heywood Floyd
On Jul 2, 2010, at 15:34 , Steven Schveighoffer wrote: > On Fri, 02 Jul 2010 09:32:39 -0400, Steven Schveighoffer > wrote: > >> On Fri, 02 Jul 2010 09:24:20 -0400, Heywood Floyd wrote: >> >>> >>> Good day! >>> >>> >>> Consider >>> >>> // - - - - >>> class Foo{} >>> auto one = new Foo();

Re: Purity of alloca()

2010-07-02 Thread BCS
Hello bearophile, Is alloca() pure? Given the same input alloca() generally returns different pointers, so it's not a pure function. But the same is true for the ptr field when you allocate an array on the heap. And the memory allocated by alloca() never escapes the function, so it looks more

Re: Is the memory address of classinfo the same for all instances of a class?

2010-07-02 Thread Steven Schveighoffer
On Fri, 02 Jul 2010 09:32:39 -0400, Steven Schveighoffer wrote: On Fri, 02 Jul 2010 09:24:20 -0400, Heywood Floyd wrote: Good day! Consider // - - - - class Foo{} auto one = new Foo(); auto two = new Foo(); writefln("one: %x two: %x", &one.classinfo, &two.classinfo); // - - - - For

Re: Is the memory address of classinfo the same for all instances of a class?

2010-07-02 Thread Steven Schveighoffer
On Fri, 02 Jul 2010 09:24:20 -0400, Heywood Floyd wrote: Good day! Consider // - - - - class Foo{} auto one = new Foo(); auto two = new Foo(); writefln("one: %x two: %x", &one.classinfo, &two.classinfo); // - - - - For me this results in two identical memory addresses "every time". Can

Is the memory address of classinfo the same for all instances of a class?

2010-07-02 Thread Heywood Floyd
Good day! Consider // - - - - class Foo{} auto one = new Foo(); auto two = new Foo(); writefln("one: %x two: %x", &one.classinfo, &two.classinfo); // - - - - For me this results in two identical memory addresses "every time". Can I rely on this? Can I design software based on the assumption

Re: dcollections ArrayList pb with mixin template

2010-07-02 Thread Steven Schveighoffer
On Thu, 01 Jul 2010 18:26:06 -0400, bearophile wrote: Steven Schveighoffer: I think a member initializer has to be a constant expression, like int i = 1. Anything else has to be done in the constructor. There are the static constructors too, for modules, structs, classes. static const

Purity of alloca()

2010-07-02 Thread bearophile
Is alloca() pure? Given the same input alloca() generally returns different pointers, so it's not a pure function. But the same is true for the ptr field when you allocate an array on the heap. And the memory allocated by alloca() never escapes the function, so it looks more pure than normal heap