D2: bug in struct postblit/dtor, or am I a burke?

2009-03-17 Thread Daniel Keep
Hi all. I can't seem to get this to work properly. I'm trying to write a copy-on-write proxy type. I'm using postblit and dtors along with the usual ctors and opAssign to manage the refcount of the shared memory. However, testing with dmd-2.026 (and a few previous versions a little while ago),

Re: C-style nested structs convert to D

2009-03-17 Thread Daniel Keep
CodexArcanum wrote: > Hey all, I'm trying to rewrite a few .h files into D so I can call a C > library. One snag I've hit is this guy: > > struct _tree_t { > _tree_t* next; > _tree_t* father; > _tree_t* sons; > } > > D won't do the nested struct thing, so I need to convert thi

C-style nested structs convert to D

2009-03-17 Thread CodexArcanum
Hey all, I'm trying to rewrite a few .h files into D so I can call a C library. One snag I've hit is this guy: struct _tree_t { _tree_t* next; _tree_t* father; _tree_t* sons; } D won't do the nested struct thing, so I need to convert this into something D will like, but

Is this atomic code correct?

2009-03-17 Thread BCS
I find my self in need of some thread safe, lock free code to update a value by way of a self referential expression x = min(x,y); Being the abstraction addict I am, I went for the general solution and came up with this: void AtomicEvalAssign(T)(ref T to, lazy T from) { T old;

Re: Compile time string parse

2009-03-17 Thread Jarrett Billingsley
On Tue, Mar 17, 2009 at 11:28 AM, Jarrett Billingsley wrote: > On Tue, Mar 17, 2009 at 10:54 AM, Paolo Invernizzi > wrote: >> Hi all, >> Someone can point me to a way of doing something like this with DMD 2.026: >> >> class A { >>    invariant(int) rev = std.conv.to!(int)("$Rev: 182 $"); >> } >>

Re: Compile time string parse

2009-03-17 Thread Jarrett Billingsley
On Tue, Mar 17, 2009 at 11:32 AM, Jarrett Billingsley wrote: Sigh, I'll get it eventually. template Atoi(string s) { static if(s.length == 1) enum int Atoi = s[$ - 1] - '0'; else enum int Atoi = 10 * Atoi!(s[0 .. $ - 1]) + (s[$ - 1] - '0'); }

Re: Compile time string parse

2009-03-17 Thread Jarrett Billingsley
On Tue, Mar 17, 2009 at 10:54 AM, Paolo Invernizzi wrote: > Hi all, > Someone can point me to a way of doing something like this with DMD 2.026: > > class A { >    invariant(int) rev = std.conv.to!(int)("$Rev: 182 $"); > } > > I've messed up with metastrings and std.conv, but I cannot find a worki

Compile time string parse

2009-03-17 Thread Paolo Invernizzi
Hi all, Someone can point me to a way of doing something like this with DMD 2.026: class A { invariant(int) rev = std.conv.to!(int)("$Rev: 182 $"); } I've messed up with metastrings and std.conv, but I cannot find a working way. Cheers, Paolo