Skip to content

Commit

Permalink
Fix coding style for declaration.dd
Browse files Browse the repository at this point in the history
  • Loading branch information
H. S. Teoh committed Aug 24, 2014
1 parent 0d3b906 commit a475d06
Showing 1 changed file with 39 additions and 30 deletions.
69 changes: 39 additions & 30 deletions declaration.dd
Expand Up @@ -368,8 +368,8 @@ alias myint = abc.Foo.bar;
--------------------
alias myint = int;

void foo(int x) { . }
void foo(myint m) { . } // error, multiply defined function foo
void foo(int x) { ... }
void foo(myint m) { ... } // error, multiply defined function foo
--------------------

$(P A symbol can be declared as an $(I alias) of another symbol.
Expand Down Expand Up @@ -433,23 +433,26 @@ alias strlen = string.strlen;
)

--------------------
class A {
class A
{
int foo(int a) { return 1; }
}

class B : A {
class B : A
{
int foo( int a, uint b ) { return 2; }
}

class C : B {
class C : B
{
int foo( int a ) { return 3; }
alias foo = B.foo;
}

class D : C {
class D : C
{
}


void test()
{
D b = new D();
Expand Down Expand Up @@ -518,14 +521,15 @@ $(GNAME Typeof):
)

--------------------
void func(int i) {
typeof(i) j; // j is of type int
typeof(3 + 6.0) x; // x is of type double
typeof(1)* p; // p is of type pointer to int
int[typeof(p)] a; // a is of type int[int*]

writefln("%d", typeof('c').sizeof); // prints 1
double c = cast(typeof(1.0))j; // cast j to double
void func(int i)
{
typeof(i) j; // j is of type int
typeof(3 + 6.0) x; // x is of type double
typeof(1)* p; // p is of type pointer to int
int[typeof(p)] a; // a is of type int[int*]

writefln("%d", typeof('c').sizeof); // prints 1
double c = cast(typeof(1.0))j; // cast j to double
}
--------------------

Expand All @@ -535,10 +539,11 @@ $(GNAME Typeof):
)

--------------------
void func() {
int i = 1;
typeof(++i) j; // j is declared to be an int, i is not incremented
writefln("%d", i); // prints 1
void func()
{
int i = 1;
typeof(++i) j; // j is declared to be an int, i is not incremented
writefln("%d", i); // prints 1
}
--------------------

Expand All @@ -559,15 +564,17 @@ $(GNAME Typeof):
--------------------
class A { }

class B : A {
typeof(this) x; // x is declared to be a B
typeof(super) y; // y is declared to be an A
class B : A
{
typeof(this) x; // x is declared to be a B
typeof(super) y; // y is declared to be an A
}

struct C {
static typeof(this) z; // z is declared to be a C
struct C
{
static typeof(this) z; // z is declared to be a C

typeof(super) q; // error, no super struct for C
typeof(super) q; // error, no super struct for C
}

typeof(this) r; // error, no enclosing struct or class
Expand All @@ -578,8 +585,9 @@ $(GNAME Typeof):
)

--------------------
struct S {
@property int foo() { return 1; }
struct S
{
@property int foo() { return 1; }
}
typeof(S.foo) n; // n is declared to be an int
--------------------
Expand All @@ -604,9 +612,10 @@ $(GNAME VoidInitializer):
)

-------------------------
void foo() {
int x = void;
writeln(x); // will print garbage
void foo()
{
int x = void;
writeln(x); // will print garbage
}
-------------------------

Expand Down

0 comments on commit a475d06

Please sign in to comment.