Re: Generic array

2011-11-17 Thread Jonathan M Davis
On Thursday, November 17, 2011 14:41 RenatoL wrote: > Ok, tk u all. > I guess this is a very poor approach if we are looking for > performance Mixing types like that in an array is not a normal thing to do. However, if you're looking to hold a specific number of items of diverse types (particula

Re: Generic array

2011-11-17 Thread RenatoL
Ok, tk u all. I guess this is a very poor approach if we are looking for performance

Make setMaxMailboxSize a property of a Tid?

2011-11-17 Thread Andrej Mitrovic
I've had this bug recently: auto workTid = spawn(&work); setMaxMailboxSize(thisTid, 1, OnCrowding.throwException); IOW, I've passed 'thisTid' instead of 'workTid' to the call. Is there any reason why had to be a global function? Tid has a private MessageBox which has the setMaxMsgs method. We ca

Re: Threads and OwnerTerminated

2011-11-17 Thread Jonathan M Davis
On Thursday, November 17, 2011 11:56 Andrej Mitrovic wrote: > This is an example from TDPL: > > import std.concurrency; > import std.exception; > import std.stdio; > > void main() > { > auto low = 0; > auto high = 100; > auto tid = spawn(&writer); > > foreach (i; low .. high) > { > writeln("Main

Re: Threads and OwnerTerminated

2011-11-17 Thread Andrej Mitrovic
Ah, I should have read the following parts where it describes thread termination, in TDPL. Woops. On 11/17/11, Andrej Mitrovic wrote: > This is an example from TDPL: > > import std.concurrency; > import std.exception; > import std.stdio; > > void main() > { > auto low = 0; > auto high = 1

Threads and OwnerTerminated

2011-11-17 Thread Andrej Mitrovic
This is an example from TDPL: import std.concurrency; import std.exception; import std.stdio; void main() { auto low = 0; auto high = 100; auto tid = spawn(&writer); foreach (i; low .. high) { writeln("Main thread: ", i); tid.send(thisTid, i); enforce(

Re: Mutable enums

2011-11-17 Thread Timon Gehr
On 11/17/2011 07:23 PM, Steven Schveighoffer wrote: On Thu, 17 Nov 2011 12:31:58 -0500, Timon Gehr wrote: On 11/17/2011 03:19 PM, Steven Schveighoffer wrote: What does writelnInferConst!T do? I'm afraid I'm not getting what you are saying. I was thinking writeln should do this: void writ

Re: Mutable enums

2011-11-17 Thread Steven Schveighoffer
On Thu, 17 Nov 2011 12:31:58 -0500, Timon Gehr wrote: On 11/17/2011 03:19 PM, Steven Schveighoffer wrote: What does writelnInferConst!T do? I'm afraid I'm not getting what you are saying. I was thinking writeln should do this: void writeln(T...)(const T args) {...} As you pointed out, t

Re: Using __traits(getMember...) in alias statement

2011-11-17 Thread Timon Gehr
On 11/17/2011 06:41 PM, Timon Gehr wrote: On 11/17/2011 06:12 PM, Tobias Pankrath wrote: It would be cool, if the following would be possible. immutable string MemberID = "M"; struct A {} struct B { alias A M; } template Member(T) { static if(__traits(hasMember, T, MemberID)) { alias __tr

Re: Using __traits(getMember...) in alias statement

2011-11-17 Thread Tobias Pankrath
> This helps a lot with the current state of affairs: > > template ID(alias x){alias x ID;} > > It will even allow funny things like this: > > alias ID!((a,b){return a+b;}) add; > > static assert(add(1,2) == 3); Nice to know, thanks!

Re: Using __traits(getMember...) in alias statement

2011-11-17 Thread Timon Gehr
On 11/17/2011 06:12 PM, Tobias Pankrath wrote: It would be cool, if the following would be possible. immutable string MemberID = "M"; struct A {} struct B { alias A M; } template Member(T) { static if(__traits(hasMember, T, MemberID)) { alias __traits(getMember, T,

Re: Mutable enums

2011-11-17 Thread Timon Gehr
On 11/17/2011 03:19 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 17:39:16 -0500, Timon Gehr wrote: On 11/16/2011 10:56 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 16:16:48 -0500, Timon Gehr wrote: On 11/16/2011 09:00 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 14:26

Using __traits(getMember...) in alias statement

2011-11-17 Thread Tobias Pankrath
It would be cool, if the following would be possible. immutable string MemberID = "M"; struct A {} struct B { alias A M; } template Member(T) { static if(__traits(hasMember, T, MemberID)) { alias __traits(getMember, T, MemberID) Member; } else alias TypeT

Re: Mutable enums

2011-11-17 Thread Steven Schveighoffer
On Wed, 16 Nov 2011 18:25:48 -0500, Timon Gehr wrote: On 11/16/2011 11:39 PM, Timon Gehr wrote: I think this is a better solution: void foo2(T: ParameterTypeTuple!foo[0])(T t){foo(t);} Then it is just a matter of applying proper value range propagation for IFTY: void bar(T: short)(T t){...}

Re: Mutable enums

2011-11-17 Thread Steven Schveighoffer
On Wed, 16 Nov 2011 17:39:16 -0500, Timon Gehr wrote: On 11/16/2011 10:56 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 16:16:48 -0500, Timon Gehr wrote: On 11/16/2011 09:00 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr wrote: On 11/16/2011 02:22