22
33$(D_S $(TITLE),
44
5- $(P There are many changes to the D programming language that affect
6- migrating source code from D1 to D2.
7- This is an outline of changes to look for and a guide to how to modify
8- the code.
9- )
5+ $(P There are many changes to the D programming language that affect
6+ migrating source code from D1 to D2.
7+ This is an outline of changes to look for and a guide to how to modify
8+ the code.
9+ )
1010
11- $(P This document is incomplete.)
11+ $(P This document is incomplete.)
1212
1313$(UL
1414 $(LI Core Language
1515 $(UL
16- $(ITEMR new_keywords, New Keywords)
17- $(ITEMR global_variables, Global Variables)
18- $(ITEMR static_arrays, Static Arrays are now Value Types)
19- $(ITEMR immutable_string, String Literals are Immutable)
16+ $(ITEMR new_keywords, New Keywords)
17+ $(ITEMR global_variables, Global Variables)
18+ $(ITEMR static_arrays, Static Arrays are now Value Types)
19+ $(ITEMR immutable_string, String Literals are Immutable)
2020 )
2121 )
2222
2828
2929$(ITEM new_keywords, New Keywords)
3030
31- $(P D2 adds the following keywords:
32- $(D_KEYWORD pure),
33- $(D_KEYWORD nothrow),
34- $(D_KEYWORD shared), and
35- $(D_KEYWORD immutable).
36- Any use of them in D1 code must be renamed.
37- Any variable names starting with two underscores
38- should be renamed.
39- )
31+ $(P D2 adds the following keywords:
32+ $(D_KEYWORD pure),
33+ $(D_KEYWORD nothrow),
34+ $(D_KEYWORD shared), and
35+ $(D_KEYWORD immutable).
36+ Any use of them in D1 code must be renamed.
37+ Any variable names starting with two underscores
38+ should be renamed.
39+ )
4040
4141$(ITEM global_variables, Global Variables)
4242
43- $(P Global variables are now, by default, stored in thread local
44- storage. To put them back in global storage, use the $(D_KEYWORD __gshared)
45- storage class:)
43+ $(P Global variables are now, by default, stored in thread local
44+ storage. To put them back in global storage, use the $(D_KEYWORD __gshared)
45+ storage class:)
4646
4747---
4848int foo = 7; // D1 code
4949$(B __gshared) int foo = 7; // D2 equivalent
5050---
5151
52- $(P Carefully consider whether or not those variables actually should
53- go into thread local storage, rather than being implicitly shared
54- among all threads.
55- )
52+ $(P Carefully consider whether or not those variables actually should
53+ go into thread local storage, rather than being implicitly shared
54+ among all threads.
55+ )
5656
5757$(ITEM static_arrays, Static Arrays are now Value Types)
5858
59- $(P In D1, a static array function parameter is passed by
60- reference, meaning a pointer to the start of the static array
61- is passed as an argument.
62- This means that any changes to the array contents made by the
63- function will be visible to the function's caller.
64- In D2, a copy of the whole static
65- array is passed as an argument. Changes to the array contents by
66- the function are not visible to the function's caller, as it is
67- a separate copy.)
59+ $(P In D1, a static array function parameter is passed by
60+ reference, meaning a pointer to the start of the static array
61+ is passed as an argument.
62+ This means that any changes to the array contents made by the
63+ function will be visible to the function's caller.
64+ In D2, a copy of the whole static
65+ array is passed as an argument. Changes to the array contents by
66+ the function are not visible to the function's caller, as it is
67+ a separate copy.)
6868
69- $(P To migrate, add the keyword $(D_KEYWORD ref) to the parameter
70- declaration:)
69+ $(P To migrate, add the keyword $(D_KEYWORD ref) to the parameter
70+ declaration:)
7171
7272---
7373void foo(int[3] array); // D1 code
@@ -76,26 +76,26 @@ void foo($(B ref) int[3] array); // D2 equivalent
7676
7777$(ITEM immutable_string, String Literals are Immutable)
7878
79- $(P String literals in D1 have type $(D char[]), but in D2 they
80- have type $(D immutable(char)[]), which is aliased for convenience
81- under the name $(D string). To migrate usually involves doing a
82- global search replace: )
79+ $(P String literals in D1 have type $(D char[]), but in D2 they
80+ have type $(D immutable(char)[]), which is aliased for convenience
81+ under the name $(D string). To migrate usually involves doing a
82+ global search replace: )
8383
84- $(TABLE
85- $(TR $(TH from)$(TH to))
86- $(TR $(TD char[])$(TD string))
87- $(TR $(TD wchar[])$(TD wstring))
88- $(TR $(TD dchar[])$(TD dstring))
89- )
84+ $(TABLE
85+ $(TR $(TH from)$(TH to))
86+ $(TR $(TD char[])$(TD string))
87+ $(TR $(TD wchar[])$(TD wstring))
88+ $(TR $(TD dchar[])$(TD dstring))
89+ )
9090
91- $(P This will take care of most of the issues.
92- For the rest, where mutable strings are desired, there will
93- be some work necessary.
94- )
91+ $(P This will take care of most of the issues.
92+ For the rest, where mutable strings are desired, there will
93+ be some work necessary.
94+ )
9595
9696)
9797
9898Macros:
99- TITLE=Migrating D1 Code to D2
100- ITEMR=$(LI $(RELATIVE_LINK2 $1, $+))
101- ITEM=$(HR)$(H3 $(ADEF $1)$+)
99+ TITLE=Migrating D1 Code to D2
100+ ITEMR=$(LI $(RELATIVE_LINK2 $1, $+))
101+ ITEM=$(HR)$(H3 $(ADEF $1)$+)
0 commit comments