Re: compare struct with string member is wield;

2011-10-11 Thread Cheng Wei
Thanks. Removing the ';' after struct and class is really helpful. The ";" keeps trapping me in C++ coding. :)

Re: compare struct with string member is wield;

2011-10-11 Thread Jonathan M Davis
On Wednesday, October 12, 2011 06:07:38 Cheng Wei wrote: > Sorry. The previous is not the one causes the problem. > Try this: > > struct S { > string str = "Hello"; // Adding an initial value here. > }; > > S g_s; > > unittest { > S s1; > S s2; > assert(s1 == s2); // Success >

Re: compare struct with string member is wield;

2011-10-11 Thread Cheng Wei
Sorry. The previous is not the one causes the problem. Try this: struct S { string str = "Hello"; // Adding an initial value here. }; S g_s; unittest { S s1; S s2; assert(s1 == s2); // Success assert(g_s == s1); // Fail auto s3 = g_s; assert(s3 == g_s);; // Even thi

Re: compare struct with string member is wield;

2011-10-11 Thread Jonathan M Davis
On Wednesday, October 12, 2011 05:16:40 Cheng Wei wrote: > struct S { > string str; > }; > > S g_s; > > unittest { > S s1; > S s2; > assert(s1 == s2); // Success > assert(g_s == s1);// Failed > } > > Is this expected? If so, may I know the reason? Thanks. It su

Re: -release compiler switch and associative arrays

2011-10-11 Thread Kagamin
Vijay Nayar Wrote: > void main() { > int[] ages = [28, 23, 40]; > assert(ages[0] == 28); > ages[3] = 54; > assert(ages[3] == 54); > } > > $ dmd -release bounds.d > $ ./bounds > # No segfault because the address is within the address space > # for the program allowed by the OS. W

compare struct with string member is wield;

2011-10-11 Thread Cheng Wei
struct S { string str; }; S g_s; unittest { S s1; S s2; assert(s1 == s2); // Success assert(g_s == s1);// Failed } Is this expected? If so, may I know the reason? Thanks.

Re: -release compiler switch and associative arrays

2011-10-11 Thread Don
On 09.10.2011 13:24, Graham Cole wrote: I understand from the documentation that the "-release" compiler switch turns off "array bounds checking for system and trusted functions". Is it correct that the following code should seg fault when compiled with "-release" ? string[string] h; h["abc"]

Re: Order of base-class constructor calls

2011-10-11 Thread Regan Heath
On Fri, 07 Oct 2011 23:02:33 +0100, Andrej Mitrovic wrote: So I'm looking for some techniques or tricks (or, dare I say, design patterns :x) you guys might have if you've ever ran into this kind of problem. The best I can come up with is a runtime solution: import std.stdio; class Base {

Re: Only one signal per object?

2011-10-11 Thread Justin Whear
>From the docs: "Different signals can be added to a class by naming the mixins." So I think something like this ought to work: mixin Signal!(string) onBlah; mixin Signal!(int, int) onClicketyClick; Peter Ravinovich wrote: > Is there a way to have several signals per object? > > The example in

Re: Order of base-class constructor calls

2011-10-11 Thread Andrej Mitrovic
Nope. Private ctors have to be called from within the same module, whether implicit or not: test.d: class Foo { private this() { } // Error: constructor main.Bar.this no match for implicit super() call in constructor } import test; class Bar : Foo { this() { } } void main() { auto b

Only one signal per object?

2011-10-11 Thread Peter Ravinovich
Is there a way to have several signals per object? The example in std.signal seams to suggest that only one signal per object can be emmited. Is it possible to have several events launched as it's possible in .NET? For example, bind one object to onClick and another to onKeyUp. Thanks

Re: Order of base-class constructor calls

2011-10-11 Thread Steven Schveighoffer
On Fri, 07 Oct 2011 18:02:33 -0400, Andrej Mitrovic wrote: Is there any way to enforce the user to call the base-class ctor via super(), so it's the first statement in his class ctor? e.g.: class Base { this(int) { } } class Derived : Base { this(int x) { super(x); /

Re: -release compiler switch and associative arrays

2011-10-11 Thread Vijay Nayar
On Tue, 11 Oct 2011 14:45:38 +, Vijay Nayar wrote: > On Sun, 09 Oct 2011 12:24:24 +0100, Graham Cole wrote: > >> I understand from the documentation that the "-release" compiler switch >> turns off "array bounds checking for system and trusted functions". >> >> Is it correct that the followi

Re: ref struct?

2011-10-11 Thread Mafi
Am 09.10.2011 19:52, schrieb bearophile: (I show this here because it's probably a silly idea, but it may a chance to learn something.) Do you like the idea of a POD that is always managed by reference, as class instances? ref struct Foo {} static assert(Foo.sizeof == 1); void main() { F

Re: -release compiler switch and associative arrays

2011-10-11 Thread Vijay Nayar
On Sun, 09 Oct 2011 12:24:24 +0100, Graham Cole wrote: > I understand from the documentation that the "-release" compiler switch > turns off "array bounds checking for system and trusted functions". > > Is it correct that the following code should seg fault when compiled > with "-release" ? > >