Re: BitArray - Is there one?

2012-05-29 Thread Era Scarecrow
On Tuesday, 29 May 2012 at 06:56:40 UTC, Dmitry Olshansky wrote: On 29.05.2012 10:52, Era Scarecrow wrote: I considered that, but then you actually limit your address space to 2^63, No you don't. Since pointer is already a pointer to word-sized object. It has 2 last bits == 0. Always. There

Re: BitArray - Is there one?

2012-05-29 Thread Dmitry Olshansky
On 29.05.2012 11:25, Era Scarecrow wrote: On Tuesday, 29 May 2012 at 06:56:40 UTC, Dmitry Olshansky wrote: On 29.05.2012 10:52, Era Scarecrow wrote: I considered that, but then you actually limit your address space to 2^63, No you don't. Since pointer is already a pointer to word-sized object

Re: Converting from string to enum by name

2012-05-29 Thread Jarl André
On Monday, 28 May 2012 at 18:53:50 UTC, Ali Çehreli wrote: On 05/28/2012 11:50 AM, "Jarl André" " wrote: > 1. Is there a way to convert from string "INFO" to LogLevel.INFO, by name? conv.to can do that: import std.conv; enum LogLevel { ALL, INFO, WARNING } void main() { enum l = to!LogL

ref fields of .tupleof

2012-05-29 Thread Sharp
Hi all! I've spend several hours to solve my problem, and I did it! But don't know why it is worked in this way: I'd like to modify all fields of an object by a specific values (for deserialization). public ref T foo(T)() { T *ret = new T; // DON'T WORK // Looping thro

Re: ref fields of .tupleof

2012-05-29 Thread Philippe Sigaud
On Tue, May 29, 2012 at 9:18 PM, Sharp wrote: What does it give if you do: >        foreach(index, unused; fields) { >                fields[index] = 1; >} ?

Re: ref fields of .tupleof

2012-05-29 Thread Ali Çehreli
On 05/29/2012 12:18 PM, Sharp wrote: > public ref T foo(T)() { > T *ret = new T; > // DON'T WORK > // Looping through fields in this way doesn't modify the object > auto fields = ret.tupleof; Looks like fields is a local copy of ret.tupleof so the following modifies just that copy. > foreach(

Exception caused by calling a pure function repeatedly

2012-05-29 Thread ixid
Having solved Project Euler 300 I wanted to explore which of the strictly superior fold set were redundant but started getting an exception thrown after a few iterations. I've changed the offending part to try to make it as impact-free as possible (my code is not pretty :)), it's now pure and

Re: Exception caused by calling a pure function repeatedly

2012-05-29 Thread ixid
It seems to leak memory with each iteration of the loop taking another 100-200K until it crashes when going over 11 MB.

Re: ref fields of .tupleof

2012-05-29 Thread Sharp
Thanks a lot Ali, I understand now! Philippe, based on what Ali said, your code will give exactly the same result because it looping through a local copy of ret.tupleof.

Re: Exception caused by calling a pure function repeatedly

2012-05-29 Thread Ali Çehreli
On 05/29/2012 07:33 PM, ixid wrote: Having solved Project Euler 300 I wanted to explore which of the strictly superior fold set were redundant but started getting an exception thrown after a few iterations. I've changed the offending part to try to make it as impact-free as possible (my code is

Re: ref fields of .tupleof

2012-05-29 Thread Jacob Carlborg
On 2012-05-29 21:18, Sharp wrote: Hi all! I've spend several hours to solve my problem, and I did it! But don't know why it is worked in this way: I'd like to modify all fields of an object by a specific values (for deserialization). If you want a serialization library: https://github.com/ja