Re: Status of AA's?

2013-03-28 Thread Rob T
Thanks for the comments. It seems that my best option is to avoid the built in AA's for now. I'll take a look at the suggested alternative solutions. One thing I'm looking for is enforced explicit additions of new key value pairs rather than the magical method used by the built in AA's, it's

Re: detect anonymous union at compile time

2013-03-28 Thread Andrej Mitrovic
On 3/28/13, cal wrote: > Just realized that format.d is able to figure it out, since it > prints #{overlap...} for unions. I can use that code, which works > regardless of protection. Thanks Ah, I didn't even know .tupleof would contain .offsetof. void main() { static if (S.tupleof[0].offset

Re: enum type changes according to context ?

2013-03-28 Thread cal
On Thursday, 28 March 2013 at 23:02:31 UTC, Timothee Cour wrote: In code below, does transTable have a well defined type? it seems to change from line 9 (string[char]) to line 10 (string[dchar])... My guess: The enum version is like saying this: auto s = translate("[", ['[' : `\[`]); here the

enum type changes according to context ?

2013-03-28 Thread Timothee Cour
In code below, does transTable have a well defined type? it seems to change from line 9 (string[char]) to line 10 (string[dchar])... rdmd -version=bad main //CT erro rdmd main //works import std.string; void main(){ version(bad){ auto transTable = ['[' : `\[`]; } else{

Re: Status of AA's?

2013-03-28 Thread 1100110
On 03/28/2013 03:05 PM, Dmitry Olshansky wrote: The built-in ones are a minefield for anything more complex then a dictionary of string->int :) Please, last I checked, they were still a minefield for that... Random crashes, basic issues with the type system... I just stopped using them... Bu

Re: detect anonymous union at compile time

2013-03-28 Thread cal
On Thursday, 28 March 2013 at 20:18:45 UTC, Andrej Mitrovic wrote: On Thursday, 28 March 2013 at 20:02:18 UTC, cal wrote: .offsetof will also require access rights to the fields. Just realized that format.d is able to figure it out, since it prints #{overlap...} for unions. I can use that code

Re: Status of AA's?

2013-03-28 Thread H. S. Teoh
On Thu, Mar 28, 2013 at 08:45:42PM +0100, Rob T wrote: > I recall some discussion about AA's being buggy and fixing the bugs > is difficult, and that there may be future changes to how AA's > operate, for example perhaps moving it to a library solution. > > So I am wondering if I should simply avo

Re: detect anonymous union at compile time

2013-03-28 Thread cal
On Thursday, 28 March 2013 at 20:18:45 UTC, Andrej Mitrovic wrote: .offsetof will also require access rights to the fields. Yeh this is the problem. I can map data layout of complex aggregates, even if the members are private, but unions mess that up. Restricting to public fields is an option

Re: detect anonymous union at compile time

2013-03-28 Thread Andrej Mitrovic
On Thursday, 28 March 2013 at 20:02:18 UTC, cal wrote: is there any way to detect the fact that fields i and f will have the same offset from S? void main() { static if (S.init.i.offsetof == S.init.f.offsetof) pragma(msg, "Union"); } (Creating an instance of S and getting the relat

Re: Status of AA's?

2013-03-28 Thread Dmitry Olshansky
28-Mar-2013 23:45, Rob T пишет: I recall some discussion about AA's being buggy and fixing the bugs is difficult, and that there may be future changes to how AA's operate, for example perhaps moving it to a library solution. So I am wondering if I should simply avoid using the built-in AA's enti

detect anonymous union at compile time

2013-03-28 Thread cal
Given: struct S { union { int i; float f; } } is there any way to detect the fact that fields i and f will have the same offset from S? (Creating an instance of S and getting the relative addresses only works if the union is public).

Status of AA's?

2013-03-28 Thread Rob T
I recall some discussion about AA's being buggy and fixing the bugs is difficult, and that there may be future changes to how AA's operate, for example perhaps moving it to a library solution. So I am wondering if I should simply avoid using the built-in AA's entirely at this time, and instead

Re: Exiting blocked threads (socket.accept)

2013-03-28 Thread Tim
On Thursday, 28 March 2013 at 17:57:47 UTC, Tim wrote: On Thursday, 28 March 2013 at 12:28:05 UTC, Martin Drasar wrote: On 28.3.2013 11:23, Tim wrote: Thanks Martin and Ali. Your solution works as long as I use the receive()-method, but what about using SocketStreams? I replaced socket.receive

Re: Exiting blocked threads (socket.accept)

2013-03-28 Thread Tim
On Thursday, 28 March 2013 at 12:28:05 UTC, Martin Drasar wrote: On 28.3.2013 11:23, Tim wrote: Thanks Martin and Ali. Your solution works as long as I use the receive()-method, but what about using SocketStreams? I replaced socket.receive() with socketStream.readLine() which isn't broken by t

Re: When to call setAssertHandler?

2013-03-28 Thread Benjamin Thaut
Am 27.03.2013 20:04, schrieb Sean Kelly: On Mar 26, 2013, at 11:37 AM, Benjamin Thaut wrote: Am 25.03.2013 23:49, schrieb Sean Kelly: On Mar 22, 2013, at 2:58 AM, Benjamin Thaut wrote: So I want to install my own assertHandler. The problem is, that even if I call "setAssetHandler" in a sh

Re: When to call setAssertHandler?

2013-03-28 Thread Benjamin Thaut
Am 28.03.2013 08:15, schrieb Jacob Carlborg: On 2013-03-22 10:58, Benjamin Thaut wrote: So I want to install my own assertHandler. The problem is, that even if I call "setAssetHandler" in a shared module constructor, and that module does not import any other modules, it is still not initialized

Re: Using inout in delegate

2013-03-28 Thread Maxim Fomin
On Thursday, 28 March 2013 at 14:16:27 UTC, Steven Schveighoffer wrote: I'm not sure what __aggr1174 is, but you can fix the e error by specifying the type for e (or specifying it as const). -Steve This is a foolishness of dmd frontend. It generates names for copies, temporaries, etc. These

Re: Orange lib help

2013-03-28 Thread Jacob Carlborg
On 2013-03-26 16:34, Dan wrote: Hi - I get some errors from this simple code: class Class_a { double[2][2] ob; } class Class_b : Class_a { int obb;} Serializer.register!(Class_b); The error is: Error: variable orange.serialization.Serializer.Serializer.serializeArray!(inout(double[2LU][2LU

Re: Using inout in delegate

2013-03-28 Thread Jacob Carlborg
On 2013-03-28 15:16, Steven Schveighoffer wrote: Like Timon said, it's a bug in inout design. I'm not sure what __aggr1174 is, but you can fix the e error by specifying the type for e (or specifying it as const). I'm assuming the issue is that the compiler is trying to generate a struct to hol

Re: Using inout in delegate

2013-03-28 Thread Kagamin
well, closure is effectively a struct, so its fields should be properly qualified, e.g. as const.

Re: Using inout in delegate

2013-03-28 Thread Steven Schveighoffer
On Thu, 28 Mar 2013 04:34:36 -0400, Jacob Carlborg wrote: The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a = [3, 4, 5]; foo(a); } Error message: main.d(9): Error: variable

Re: isExpression with bool template parameter

2013-03-28 Thread Kenji Hara
On Tuesday, 26 March 2013 at 14:26:59 UTC, cal wrote: I guess the tuple version is fine, it is just surprising that only one of the three parameter types can be directly matched. It is also surprising that this example from the docs works: Because 'Tuple' is a template, not a type. Please reca

Re: Orange lib help

2013-03-28 Thread Jacob Carlborg
On 2013-03-26 16:34, Dan wrote: Hi - I get some errors from this simple code: class Class_a { double[2][2] ob; } class Class_b : Class_a { int obb;} Serializer.register!(Class_b); The error is: Error: variable orange.serialization.Serializer.Serializer.serializeArray!(inout(double[2LU][2LU

Re: Exiting blocked threads (socket.accept)

2013-03-28 Thread Martin Drasar
On 28.3.2013 11:23, Tim wrote: > Thanks Martin and Ali. Your solution works as long as I use the > receive()-method, but what about using SocketStreams? I replaced > socket.receive() with socketStream.readLine() which isn't broken by the > solution above... If you check the documentation, you will

Re: Using inout in delegate

2013-03-28 Thread Timon Gehr
On 03/28/2013 09:34 AM, Jacob Carlborg wrote: The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a = [3, 4, 5]; foo(a); } Error message: main.d(9): Error: variable main.foo.__la

Re: Exiting blocked threads (socket.accept)

2013-03-28 Thread Tim
On Thursday, 28 March 2013 at 07:57:07 UTC, Martin Drašar wrote: Dne 27.3.2013 22:38, Tim napsal(a): Thanks! I've never used message passing and I'm currently a bit confused how it works (I came from the Java-area where message passing isn't necessary for something like that)... are there any

Using inout in delegate

2013-03-28 Thread Jacob Carlborg
The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a = [3, 4, 5]; foo(a); } Error message: main.d(9): Error: variable main.foo.__lambda1.__aggr1174 inout variables can only be declare

Re: Exiting blocked threads (socket.accept)

2013-03-28 Thread Martin Drašar
Dne 27.3.2013 22:38, Tim napsal(a): Thanks! I've never used message passing and I'm currently a bit confused how it works (I came from the Java-area where message passing isn't necessary for something like that)... are there any information/examples about message passing? I sill can't get it to w

Re: When to call setAssertHandler?

2013-03-28 Thread Jacob Carlborg
On 2013-03-22 10:58, Benjamin Thaut wrote: So I want to install my own assertHandler. The problem is, that even if I call "setAssetHandler" in a shared module constructor, and that module does not import any other modules, it is still not initialized first. Is there a way to set the assert before