Re: The is expression

2011-04-02 Thread spir
On 04/02/2011 12:14 AM, enuhtac wrote: template isA( T ) { static if( is( T U == A!( U, s ), string s ) ) enum bool isA = true; else enum bool isA = false; }; What does ", string s" do here inside the is expression? Denis -- _ vita es estrany spir.wi

Re: The is expression

2011-04-02 Thread enuhtac
Am 02.04.2011 11:24, schrieb spir: > On 04/02/2011 12:14 AM, enuhtac wrote: >> template isA( T ) >> { >> static if( is( T U == A!( U, s ), string s ) ) >> enum bool isA = true; >> else >> enum bool isA = false; >> }; > > What does ", string s" do here inside the is expre

Re: The is expression

2011-04-02 Thread enuhtac
Am 02.04.2011 04:00, schrieb Caligo: > On Fri, Apr 1, 2011 at 5:14 PM, enuhtac wrote: >> Hello, >> >> the "is" expression is a great feature of D - but its use is not very >> intuitive, at least for me. >> I'm trying to write a template that figures out if the template >> parameter is of a given t

Static array size limit

2011-04-02 Thread simendsjo
http://digitalmars.com/d/2.0/arrays.html says static arrays are limited to 16mb, but I can only allocate 1mb. My fault, or bug? enum size = (16 * 1024 * 1024) / int.sizeof; //int[size] a; // Error: index 4194304 overflow for static array enum size2 = (16 * 1000 * 1000) /

Re: Static array size limit

2011-04-02 Thread simendsjo
This is using dmd 2.052 on windows by the way.

Re: Static array size limit

2011-04-02 Thread Jonathan M Davis
On 2011-04-02 06:21, simendsjo wrote: > http://digitalmars.com/d/2.0/arrays.html says static arrays are > limited to 16mb, but I can only allocate 1mb. > My fault, or bug? > > enum size = (16 * 1024 * 1024) / int.sizeof; > //int[size] a; // Error: index 4194304 overflow for static >

Re: Static array size limit

2011-04-02 Thread simendsjo
I think you missed my "/int.sizeof" at the end. enum size = (16*1024*1024)/int.sizeof; int[size] a; // "Error index overflow for static" as expected int[size-1] b; // stack overflow int[250_001] c; // stack overflow int[250_000] d; // ok

immutable arrays and .sort/.reverse

2011-04-02 Thread simendsjo
immutable(int[]) a = [1,2,3]; assert(!is(typeof({a[0] = 0;}))); // cannot change elements assert(!is(typeof({a = [1,1,1];}))); // cannot rebind // but I'm allowed to sort in place... a.reverse; assert(a == [3,2,1]);

Re: Static array size limit

2011-04-02 Thread bearophile
simendsjo: > http://digitalmars.com/d/2.0/arrays.html says static arrays are > limited to 16mb, but I can only allocate 1mb. > My fault, or bug? It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304 ints. I don't know why it's designed this way... I'd like 4_194_304 ints

Re: immutable arrays and .sort/.reverse

2011-04-02 Thread bearophile
simendsjo: > // but I'm allowed to sort in place... > a.reverse; > assert(a == [3,2,1]); It's a known bug, already in Bugzilla. Bye, bearophile

Re: How do I exhaust a thread's message queue?

2011-04-02 Thread Andrej Mitrovic
It turns out the receiveTimeout technique didn't work well for me. In my case, there's a timer which spawns a high-priority thread calling `foo` several hundred times per second. What I really needed is to exhaust the message queue, and then do some other work after that. So I've added a `shared in

Re: Static array size limit

2011-04-02 Thread simendsjo
On 02.04.2011 16:45, bearophile wrote: simendsjo: http://digitalmars.com/d/2.0/arrays.html says static arrays are limited to 16mb, but I can only allocate 1mb. My fault, or bug? It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304 ints. I don't know why it's designe

Re: Static array size limit

2011-04-02 Thread bearophile
simendsjo: > The main problem is that it gives a Stack Overflow already at 250_001 I meant with the array as a global variable. The stack on Windows can be set very large too, with -L/STACK:1000 Bye, bearophile