Re: BitArray/BitFields - Resumed and polishing

2013-01-03 Thread Dmitry Olshansky
1/3/2013 6:05 AM, Era Scarecrow пишет: On Wednesday, 2 January 2013 at 21:00:38 UTC, Dmitry Olshansky wrote: 12/31/2012 9:35 PM, Era Scarecrow пишет: Personally I believe that if we introduce a slice of a BitArray as a separate range type that represents a view of array (but can't be appended

Re: structs are now lvalues - what is with "auto ref"?

2013-01-03 Thread jerro
On Wednesday, 2 January 2013 at 01:05:09 UTC, Namespace wrote: Maybe it's best to just make a pull request and let others inspect the changes and discuss the semantics of auto ref. Or maybe it would be better to make a thread in digitalmars.D first? In my opinion you should do both, thread an

Re: BitArray/BitFields - Resumed and polishing

2013-01-03 Thread Era Scarecrow
On Thursday, 3 January 2013 at 07:57:46 UTC, Dmitry Olshansky wrote: 1/3/2013 6:05 AM, Era Scarecrow wrote: Hm, I'd think that having Slice type be: BitArraySlice{ BitArray* bp; size_t start, end; // all else forwards to the pointed array } should work avoiding the most of code duplication. W

Re: BitArray/BitFields - Resumed and polishing

2013-01-03 Thread Dmitry Olshansky
1/3/2013 2:20 PM, Era Scarecrow пишет: On Thursday, 3 January 2013 at 07:57:46 UTC, Dmitry Olshansky wrote: 1/3/2013 6:05 AM, Era Scarecrow wrote: Hm, I'd think that having Slice type be: BitArraySlice{ BitArray* bp; size_t start, end; // all else forwards to the pointed array } should work

Const and enum optimizations

2013-01-03 Thread Phil Lavoie
Hi, I have a question concerning compiler optimizations and their likelihood for const vs. enum declarations. I came across some code recently that had a bunch of const declarations that were extracted from a C header. In this very header, those definitions are in fact #define clauses. I w

Re: asynchronous communication between threads

2013-01-03 Thread Dmitry Olshansky
02-Jan-2013 03:54, Charles Hixson пишет: If I were to use the below as an asynchronous communication channel, would it avoid deadlocks (presuming that only Cell called Msg) and that when a thread activated Cell, the first thing it did was process it's mailbox? Also, if only around 7 cells were cr

Re: A opIndexUnary quiz

2013-01-03 Thread Peter Summerland
On Thursday, 3 January 2013 at 07:03:23 UTC, monarch_dodra wrote: On Thursday, 3 January 2013 at 00:08:12 UTC, Peter Summerland wrote: On Wednesday, 2 January 2013 at 03:52:21 UTC, bearophile wrote: Era Scarecrow: Well I see that you have opIndexUnary twice; According to the manual you wouldn

Re: Const and enum optimizations

2013-01-03 Thread Jonathan M Davis
On Thursday, January 03, 2013 16:58:11 Phil Lavoie wrote: > Hi, > > I have a question concerning compiler optimizations and their > likelihood for const vs. enum declarations. > > I came across some code recently that had a bunch of const > declarations that were extracted from a C header. In thi

Re: Const and enum optimizations

2013-01-03 Thread Phil Lavoie
But if your concern is const variables at module scope being optimized out of existence, it is my understanding that they won't be. All right, thanks for your answer! My concern is indeed const variable at module scope. I felt like using enums for #define translations were more appropriate, a

Re: asynchronous communication between threads

2013-01-03 Thread Charles Hixson
On 01/03/2013 08:40 AM, Dmitry Olshansky wrote: 02-Jan-2013 03:54, Charles Hixson пишет: If I were to use the below as an asynchronous communication channel, would it avoid deadlocks (presuming that only Cell called Msg) and that when a thread activated Cell, the first thing it did was process i

Re: asynchronous communication between threads

2013-01-03 Thread Dmitry Olshansky
03-Jan-2013 22:38, Charles Hixson пишет: On 01/03/2013 08:40 AM, Dmitry Olshansky wrote: 02-Jan-2013 03:54, Charles Hixson пишет: If I were to use the below as an asynchronous communication channel, would it avoid deadlocks (presuming that only Cell called Msg) and that when a thread activated

Re: BitArray/BitFields - Resumed and polishing

2013-01-03 Thread Era Scarecrow
On Thursday, 3 January 2013 at 15:48:50 UTC, Dmitry Olshansky wrote: 1/3/2013 2:20 PM, Era Scarecrow wrote: Suddenly it won't work and slicing is only a range and can only be used in foreach. No surprise here. Basically container != range over it. It all flows from there. Range doesn't have a

Re: BitArray/BitFields - Resumed and polishing

2013-01-03 Thread Dmitry Olshansky
04-Jan-2013 00:11, Era Scarecrow пишет: On Thursday, 3 January 2013 at 15:48:50 UTC, Dmitry Olshansky wrote: 1/3/2013 2:20 PM, Era Scarecrow wrote: Suddenly it won't work and slicing is only a range and can only be used in foreach. No surprise here. Basically container != range over it. It al

Re: Const and enum optimizations

2013-01-03 Thread Ali Çehreli
On 01/03/2013 07:58 AM, Phil Lavoie wrote: > header.c: > #define MY_CONST 1 > ... > module.d: > enum { > MY_CONST = 1 > } Further, there is no need for that anonymous scope in D: enum MY_CONST = 1; Even further, I am one of those who reserve all capitals to macros. Since there are no macr

Re: Const and enum optimizations

2013-01-03 Thread Jonathan M Davis
On Thursday, January 03, 2013 13:34:16 Ali Çehreli wrote: > On 01/03/2013 07:58 AM, Phil Lavoie wrote: > > header.c: > > #define MY_CONST 1 > > ... > > module.d: > > enum { > > MY_CONST = 1 > > } > > Further, there is no need for that anonymous scope in D: > > enum MY_CONST = 1; > > Even further

Re: BitArray/BitFields - Resumed and polishing

2013-01-03 Thread Era Scarecrow
On Thursday, 3 January 2013 at 21:15:19 UTC, Dmitry Olshansky wrote: 04-Jan-2013 00:11, Era Scarecrow wrote: Appending a slice *to* BitArray is perfectly fine as in fact any range of bool (or bit if you like). Any array-like or string-like container has to support appending a range of elemen

Compile Time Argument Evaluation

2013-01-03 Thread DProgrammer2
Hello, I was wondering if there would be some way to verify arguments to a function at compile time, but at runtime call only one function (in D2). To clarify what I mean: Say you have something like printf() printf(const char[] format, ...) I want to be able to make sure the arguments pas

Re: Compile Time Argument Evaluation

2013-01-03 Thread bearophile
DProgrammer2: If there's no good way to do this that's fine. I bring this up because I saw https://github.com/xomboverlord/xomb/blob/unborn/kernel/core/kprintf.d which was neat, but it generates a new kprintf function for different arguments. I thought it'd be interesting to try and have th

Re: asynchronous communication between threads

2013-01-03 Thread Charles Hixson
On 01/03/2013 11:34 AM, Dmitry Olshansky wrote: 03-Jan-2013 22:38, Charles Hixson пишет: On 01/03/2013 08:40 AM, Dmitry Olshansky wrote: 02-Jan-2013 03:54, Charles Hixson пишет: If I were to use the below as an asynchronous communication channel, would it avoid deadlocks (presuming that only C