File tree Expand file tree Collapse file tree 13 files changed +29
-29
lines changed Expand file tree Collapse file tree 13 files changed +29
-29
lines changed Original file line number Diff line number Diff line change @@ -369,9 +369,9 @@ $(H4 The D Way)
369369 concatenate and append, respectively:
370370
371371----------------------------
372- char[] s1;
373- char[] s2;
374- char[] s;
372+ string s1;
373+ string s2;
374+ string s;
375375
376376s = s1 ~ s2;
377377s ~= "hello";
@@ -612,7 +612,7 @@ $(H4 The D Way)
612612 lookup becomes straightforward:
613613
614614----------------------------
615- void dostring(char[] s)
615+ void dostring(string s)
616616{
617617 switch (s)
618618 {
@@ -1349,12 +1349,12 @@ $(H4 The D Way)
13491349-----------------------------
13501350class Symbol
13511351{
1352- char[] id;
1352+ string id;
13531353 Symbol left;
13541354 Symbol right;
13551355}
13561356
1357- Symbol symbol_membersearch(Symbol[] table, char[] id)
1357+ Symbol symbol_membersearch(Symbol[] table, string id)
13581358{
13591359 Symbol sm;
13601360
Original file line number Diff line number Diff line change @@ -342,7 +342,7 @@ class Mailer
342342 void Send(Message msg)
343343 {
344344 {
345- char[] origTitle = msg.Title();
345+ const origTitle = msg.Title();
346346 scope(exit) msg.SetTitle(origTitle);
347347 msg.SetTitle("[Sending] " ~ origTitle);
348348 Copy(msg, "Sent");
Original file line number Diff line number Diff line change @@ -400,7 +400,7 @@ printf("string = '%s'\n", s);
400400 Attempting this in D, as in:
401401
402402---------------------------------
403- char[] s;
403+ string s;
404404s = "foo";
405405printf("string = '%s'\n", s);
406406---------------------------------
@@ -413,7 +413,7 @@ printf("string = '%s'\n", s);
413413 $(B %.*s) format:
414414
415415---------------------------------
416- char[] s;
416+ string s;
417417s = "foo";
418418printf("string = '%.*s'\n", s);
419419---------------------------------
Original file line number Diff line number Diff line change 3434)
3535
3636---
37- void log(char[] message)
37+ void log(const( char) [] message)
3838{
3939 if (logging)
4040 fwritefln(logfile, message);
@@ -95,7 +95,7 @@ is possible in the D programming language using a delegate parameter:
9595)
9696
9797---
98- void log(char[] delegate() dg)
98+ void log(const( char) [] delegate() dg)
9999{
100100 if (logging)
101101 fwritefln(logfile, dg());
@@ -123,7 +123,7 @@ The functions then become:
123123)
124124
125125---
126- void log(lazy char[] dg)
126+ void log(lazy const( char) [] dg)
127127{
128128 if (logging)
129129 fwritefln(logfile, dg());
@@ -260,7 +260,7 @@ function:
260260)
261261
262262---
263- Abc Enforce(Abc p, lazy char[] msg)
263+ Abc Enforce(Abc p, lazy const( char) [] msg)
264264{
265265 if (!p)
266266 throw new Exception(msg());
@@ -280,7 +280,7 @@ template function:
280280)
281281
282282---
283- T Enforce(T)(T p, lazy char[] msg)
283+ T Enforce(T)(T p, lazy const( char) [] msg)
284284{
285285 if (!p)
286286 throw new Exception(msg());
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ dchar h[] = TEXT("hello");
203203 $(DWAY
204204
205205---------
206- dchar[] h = "hello";
206+ dstring h = "hello";
207207---------
208208
209209
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ would be run (implies --chatty))
9595
9696$(DT $(B --eval)=code) $(DD evaluate code including it in
9797---
98- void main(char[] [] args) { ... }
98+ void main(string [] args) { ... }
9999---
100100(multiple --eval allowed, will be
101101evaluated in turn))
Original file line number Diff line number Diff line change @@ -1014,7 +1014,7 @@ new Foo;
10141014------
10151015class Foo
10161016{
1017- this(char[] a) { ... }
1017+ this(string a) { ... }
10181018
10191019 new(uint size, int x, int y)
10201020 {
Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ $(DD Explains the return value of the function.
335335 * Returns: The contents of the file.
336336 */
337337
338- void[] readFile(char[] filename) { ... }
338+ void[] readFile(const( char) [] filename) { ... }
339339------------------------------------
340340
341341$(DT $(B See$(UNDERSCORE)Also:))
@@ -364,7 +364,7 @@ $(DD Lists exceptions thrown and under what circumstances they are thrown.)
364364 * Throws: WriteException on failure.
365365 */
366366
367- void writeFile(char[] filename) { ... }
367+ void writeFile(string filename) { ... }
368368------------------------------------
369369
370370$(DT $(B Version:))
Original file line number Diff line number Diff line change 9393
9494$(P The solution is to use exception handling to report errors. All
9595errors are objects derived from abstract class $(D Error). $(D Error)
96- has a pure virtual function called toString() which produces a $(D char[] )
96+ has a pure virtual function called toString() which produces a $(D string )
9797with a human readable description of the error.)
9898
9999$(P If code detects an error like "out of memory," then an Error is thrown
Original file line number Diff line number Diff line change @@ -496,7 +496,7 @@ $(GNAME InExpression):
496496$(P An associative array can be tested to see if an element is in the array:)
497497
498498 -------------
499- int foo[char[] ];
499+ int foo[string ];
500500 ...
501501 if ("hello" in foo)
502502 ...
@@ -2092,7 +2092,7 @@ import std.stdio, std.typecons;
20922092void main()
20932093{
20942094 alias Tup = Tuple!(int, string);
2095- alias AA = long[char[] ];
2095+ alias AA = long[string ];
20962096
20972097 static if (is(Tup : Template!Args, alias Template, Args...))
20982098 {
@@ -2102,10 +2102,10 @@ void main()
21022102 writeln(typeid(Args[1])); // immutable(char)[]
21032103 }
21042104
2105- static if (is(AA T : T[U], U : const char[] ))
2105+ static if (is(AA T : T[U], U : string ))
21062106 {
21072107 writeln(typeid(T)); // long
2108- writeln(typeid(U)); // const char[]
2108+ writeln(typeid(U)); // string
21092109 }
21102110
21112111 static if (is(AA A : A[B], B : int))
You can’t perform that action at this time.
0 commit comments