Re: Multi-file byte comparison tool. What would you have done differently?

2011-08-07 Thread Pelle
On Fri, 05 Aug 2011 18:43:27 +0200, Kai Meyer wrote: On 08/05/2011 03:02 AM, Pelle wrote: Don't declare variables until you need them, just leave bytes_read and bytes_max here. Is there a performance consideration? Or is it purely a style or D-Factor suggestion? Just style and D-factor :

Re: More than one invariant per struct/class

2011-08-07 Thread Pelle
On Sat, 06 Aug 2011 22:53:31 +0200, Jonathan M Davis wrote: Feel free to create a feature request on it. It may even get the language changed. However, having more than one invariant complicates things a bit, since right now, it's easy for the runtime to just call the one invariant. If y

Re: (int << ulong) == int ?

2011-08-07 Thread bearophile
Brad Roberts: > Which has nothing to do with the question about integral promotion. The original code was similar to this C code: int main() { unsigned int j = 42; unsigned long long k = 1 << (unsigned long long)j; return k; } If you process it with a simple C lint you get a warnin

Re: (int << ulong) == int ?

2011-08-07 Thread Brad Roberts
Which has nothing to do with the question about integral promotion. On Aug 7, 2011, at 3:07 PM, bearophile wrote: > Dmitry Olshansky: > >> Sorry for the noise. > > It's not noise, and you don't need to be sorry, in my opinion it's a D/DMD > design fault. Clang gives an error on code like th

Re: (int << ulong) == int ?

2011-08-07 Thread Dmitry Olshansky
On 08.08.2011 2:07, bearophile wrote: Dmitry Olshansky: Sorry for the noise. It's not noise, and you don't need to be sorry, in my opinion it's a D/DMD design fault. Clang gives an error on code like that: http://blog.llvm.org/2011/05/c-at-google-here-be-dragons.html See the error: example2.

Re: (int << ulong) == int ?

2011-08-07 Thread bearophile
Dmitry Olshansky: > Sorry for the noise. It's not noise, and you don't need to be sorry, in my opinion it's a D/DMD design fault. Clang gives an error on code like that: http://blog.llvm.org/2011/05/c-at-google-here-be-dragons.html See the error: example2.cc:12:25: error: shift result (10737418

Re: (int << ulong) == int ?

2011-08-07 Thread Jonathan M Davis
On Monday 08 August 2011 01:42:37 Dmitry Olshansky wrote: > > You have to deal with integer promotions and all that when doing > > arithmetic, because arithmetic needs to be done with a like number of > > bits on both sides of the operation. But with shifting, all your doing > > is asking it to shi

Re: (int << ulong) == int ?

2011-08-07 Thread Dmitry Olshansky
You have to deal with integer promotions and all that when doing arithmetic, because arithmetic needs to be done with a like number of bits on both sides of the operation. But with shifting, all your doing is asking it to shift some number of bits. The type which holds the number of bits shouldn'

Re: (int << ulong) == int ?

2011-08-07 Thread Jonathan M Davis
On Monday 08 August 2011 00:33:31 Dmitry Olshansky wrote: > Just lost the best part of an hour figuring the cause of this small > problem, consider: > > void main() > { > uint j = 42; > ulong k = 1< ulong m = 1UL< assert(k == 1024);//both asserts do pass >

(int << ulong) == int ?

2011-08-07 Thread Dmitry Olshansky
Just lost the best part of an hour figuring the cause of this small problem, consider: void main() { uint j = 42; ulong k = 1

Foreach over tuple of arrays?

I have a tuple of arrays of different types, but want to call a template function on each element. How would I do this? void foo(T)(T elem) { ... } I tried like this: ArrayTuple!(T) data; void iterate(alias func, uint n)() { static if(n < T.length)

Re: Something weird with threads.

- Error: template std.concurrency.spawn(T...) cannot deduce template function from argument types !()(void delegate()) As the message already tells a class method yields a delegate and not a function. Check if that method could be made static. But if you really need to do it this way, you m

Something weird with threads.

While messing with threads from std.concurrency, I've been getting this weird problem. The code below, runs perfectly fine. --- import std.concurrency; void main( ) { spawn( &func ); } void func( ) { } --