Skip to content

Code sample fixes and additions, updated symbol names. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from May 28, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b4d9db7
A wild ddoc macro was hiding code all these years.
AndrejMitrovic May 20, 2011
c034d93
code sample: rt is still a short[], write will not output [257]
AndrejMitrovic May 20, 2011
026bb00
Code sample: dup should be used when assigning string literals to cha…
AndrejMitrovic May 20, 2011
91b6556
Changed ArrayBoundsError to RangeError.
AndrejMitrovic May 20, 2011
4e7fb88
Code samples: Changed inconsistent use of X and S to represent a stru…
AndrejMitrovic May 20, 2011
5eb54b1
Added missing closing brace.
AndrejMitrovic May 20, 2011
e301483
Changed import std.hiddenfunc to import core.exception. Changed char[…
AndrejMitrovic May 20, 2011
70fb890
Changed hash key type from char[] to string. Changed f typo to foo. C…
AndrejMitrovic May 20, 2011
a04156c
quickfix: idup wasn't necessary
AndrejMitrovic May 20, 2011
27d0aec
Changed import core.dll_helper to import core.sys.windows.dll
AndrejMitrovic May 20, 2011
c561a18
Added missing 'test' module declaration. .stringof has different resu…
AndrejMitrovic May 20, 2011
6ff4106
Added explanation of scope storage class. Fixes issue 5458.
AndrejMitrovic May 21, 2011
6ab0450
Although custom class allocators might be going away in the future, t…
AndrejMitrovic May 21, 2011
6a72ce0
OutOfMemoryException is now OutOfMemoryError
AndrejMitrovic May 21, 2011
3a34cf5
Added further explanation of how the the immutable keyword applies to…
AndrejMitrovic May 21, 2011
208f350
Properly fix this example to be inline with the documentation.
AndrejMitrovic May 27, 2011
4da4b4f
Hide typedef, add an int, and detab the whole file
AndrejMitrovic May 28, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions arrays.dd
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ try
array[i] = 5;
}
}
catch (ArrayBoundsError)
catch (RangeError)
{
// terminate loop
}
Expand Down Expand Up @@ -1394,5 +1394,5 @@ Macros:
WIKI=Arrays
DOLLAR=$
FOO=
CATEGORY_SPEC=$0
DOLLAR=$
CATEGORY_SPEC=$0
DOLLAR=$
4 changes: 2 additions & 2 deletions class.dd
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ A a = new A(3);
$(OL
$(LI Storage is allocated for the object.
If this fails, rather than return $(B null), an
$(B OutOfMemoryException) is thrown.
$(B OutOfMemoryError) is thrown.
Thus, tedious checks for null references are unnecessary.
)

Expand Down Expand Up @@ -1178,7 +1178,7 @@ $(SECTION3 <a name="ConstClass">Const, Immutable and Shared Classes</a>,
Macros:
TITLE=Classes
WIKI=Class
CATEGORY_SPEC=$0
CATEGORY_SPEC=$0
GLINK=$(LINK2 #$0, $(I $0))
GNAME=<a name=$0>$(I $0)</a>
DOLLAR=$
Expand Down
39 changes: 29 additions & 10 deletions const3.dd
Original file line number Diff line number Diff line change
Expand Up @@ -317,25 +317,44 @@ $(SECTION2 Immutable Member Functions,

---
struct S
{ int x;
{
int x;

immutable void foo()
void foo() immutable
{
x = 4; // error, x is immutable
this.x = 4; // error, x is immutable
x = 4; // error, x is immutable
this.x = 4; // error, x is immutable
}
}
---
$(P Note that using $(D_KEYWORD immutable) on the left hand side of a method does not apply to the return type:
)

$(P The $(D_KEYWORD const) and $(D_KEYWORD immutable) function
attributes
can also appear after the closing parenthesis of
the parameter list:
---
struct S
{
immutable int[] bar() // bar is still immutable, return type is not!
{
}
}
---
$(P To make the return type $(D_KEYWORD immutable), you need to surround the return type with parentheses:
)

---
struct S
{
void bar() immutable
immutable(int[]) bar() // bar is now mutable, return type is immutable.
{
}
}
---
$(P To make both the return type and the method $(D_KEYWORD immutable), you can write:
)
---
struct S
{
immutable(int[]) bar() immutable
{
}
}
Expand Down Expand Up @@ -566,7 +585,7 @@ Macros:
N=$(TD $(RED No))
TITLE=Const and Immutable
WIKI=ConstInvariant
CATEGORY_SPEC=$0
CATEGORY_SPEC=$0
NO=<td class="compNo">No</td>
NO1=<td class="compNo"><a href="$1">No</a></td>
YES=<td class="compYes">Yes</td>
Expand Down
4 changes: 2 additions & 2 deletions dll.dd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $(D_S Writing Win32 DLLs in D,

--------------------------------
import std.c.windows.windows;
import core.dll_helper;
import core.sys.windows.dll;

__gshared HINSTANCE g_hInst;

Expand Down Expand Up @@ -629,4 +629,4 @@ C:>
Macros:
TITLE=Writing Win32 DLLs
WIKI=DLLs
CATEGORY_HOWTOS=$0
CATEGORY_HOWTOS=$0
6 changes: 3 additions & 3 deletions expression.dd
Original file line number Diff line number Diff line change
Expand Up @@ -1231,10 +1231,10 @@ void main()
{
// cast array literal
const short[] ct = cast(short[]) [cast(byte)1, 1];
writeln(ct); // writes [1 1]
writeln(ct); // writes [1, 1]

// cast other array expression
short[] rt = cast(short[]) [cast(byte)1, 1].dup;
short[] rt = cast(short[]) [cast(byte)1, cast(byte)1].dup;
writeln(rt); // writes [257]
}
---
Expand Down Expand Up @@ -1931,7 +1931,7 @@ void main()
Macros:
TITLE=Expressions
WIKI=Expression
CATEGORY_SPEC=$0
CATEGORY_SPEC=$0
GLINK=$(LINK2 #$0, $(I $0))
GNAME=<a name=$0>$(I $0)</a>
DOLLAR=$
Expand Down
22 changes: 14 additions & 8 deletions function.dd
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ $(V2
same name in the base class, even if the types of the parameters
in the base class functions are different. If, through
implicit conversions to the base class, those other functions do
get called, an $(CODE std.HiddenFuncError) exception is raised:
get called, a $(CODE core.exception.HiddenFuncError) exception is raised:
)
---
import std.hiddenfunc;
import core.exception;

class A
{
Expand All @@ -442,15 +442,16 @@ class B : A
}

void foo(A a)
{ int i;
{
int i;
try
{
a.$(B set)(3); // error, throws runtime exception since
// A.set(int) should not be available from B
}
catch ($(B HiddenFuncError) o)
{
i = 1;
i = 1;
}
assert(i == 1);
}
Expand Down Expand Up @@ -696,6 +697,11 @@ int foo(in int x, out int y, ref int z, int q);
The $(B in) storage class is equivalent to $(B const scope).
)

$(P
The $(B scope) storage class means that references in the parameter
cannot be escaped (e.g. assigned to a global variable).
)

$(P
If no storage class is specified, the parameter becomes a mutable
copy of its argument.
Expand Down Expand Up @@ -1071,12 +1077,12 @@ int sum(int[3] ar ...)
class Foo
{
int x;
char[] s;
string s;

this(int x, char[] s)
this(int x, string s)
{
this.x = x;
this.s = s;
this.x = x;
this.s = s;
}
}

Expand Down
Loading