Thanks. Removing the ';' after struct and class is really helpful. The
";" keeps trapping me in C++ coding. :)
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
>
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
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
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
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.
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"]
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 {
>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
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
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
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);
/
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
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
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" ?
>
>
15 matches
Mail list logo