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)
369
369
concatenate and append, respectively:
370
370
371
371
----------------------------
372
- char[] s1;
373
- char[] s2;
374
- char[] s;
372
+ string s1;
373
+ string s2;
374
+ string s;
375
375
376
376
s = s1 ~ s2;
377
377
s ~= "hello";
@@ -612,7 +612,7 @@ $(H4 The D Way)
612
612
lookup becomes straightforward:
613
613
614
614
----------------------------
615
- void dostring(char[] s)
615
+ void dostring(string s)
616
616
{
617
617
switch (s)
618
618
{
@@ -1349,12 +1349,12 @@ $(H4 The D Way)
1349
1349
-----------------------------
1350
1350
class Symbol
1351
1351
{
1352
- char[] id;
1352
+ string id;
1353
1353
Symbol left;
1354
1354
Symbol right;
1355
1355
}
1356
1356
1357
- Symbol symbol_membersearch(Symbol[] table, char[] id)
1357
+ Symbol symbol_membersearch(Symbol[] table, string id)
1358
1358
{
1359
1359
Symbol sm;
1360
1360
Original file line number Diff line number Diff line change @@ -342,7 +342,7 @@ class Mailer
342
342
void Send(Message msg)
343
343
{
344
344
{
345
- char[] origTitle = msg.Title();
345
+ const origTitle = msg.Title();
346
346
scope(exit) msg.SetTitle(origTitle);
347
347
msg.SetTitle("[Sending] " ~ origTitle);
348
348
Copy(msg, "Sent");
Original file line number Diff line number Diff line change @@ -400,7 +400,7 @@ printf("string = '%s'\n", s);
400
400
Attempting this in D, as in:
401
401
402
402
---------------------------------
403
- char[] s;
403
+ string s;
404
404
s = "foo";
405
405
printf("string = '%s'\n", s);
406
406
---------------------------------
@@ -413,7 +413,7 @@ printf("string = '%s'\n", s);
413
413
$(B %.*s) format:
414
414
415
415
---------------------------------
416
- char[] s;
416
+ string s;
417
417
s = "foo";
418
418
printf("string = '%.*s'\n", s);
419
419
---------------------------------
Original file line number Diff line number Diff line change 34
34
)
35
35
36
36
---
37
- void log(char[] message)
37
+ void log(const( char) [] message)
38
38
{
39
39
if (logging)
40
40
fwritefln(logfile, message);
@@ -95,7 +95,7 @@ is possible in the D programming language using a delegate parameter:
95
95
)
96
96
97
97
---
98
- void log(char[] delegate() dg)
98
+ void log(const( char) [] delegate() dg)
99
99
{
100
100
if (logging)
101
101
fwritefln(logfile, dg());
@@ -123,7 +123,7 @@ The functions then become:
123
123
)
124
124
125
125
---
126
- void log(lazy char[] dg)
126
+ void log(lazy const( char) [] dg)
127
127
{
128
128
if (logging)
129
129
fwritefln(logfile, dg());
@@ -260,7 +260,7 @@ function:
260
260
)
261
261
262
262
---
263
- Abc Enforce(Abc p, lazy char[] msg)
263
+ Abc Enforce(Abc p, lazy const( char) [] msg)
264
264
{
265
265
if (!p)
266
266
throw new Exception(msg());
@@ -280,7 +280,7 @@ template function:
280
280
)
281
281
282
282
---
283
- T Enforce(T)(T p, lazy char[] msg)
283
+ T Enforce(T)(T p, lazy const( char) [] msg)
284
284
{
285
285
if (!p)
286
286
throw new Exception(msg());
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ dchar h[] = TEXT("hello");
203
203
$(DWAY
204
204
205
205
---------
206
- dchar[] h = "hello";
206
+ dstring h = "hello";
207
207
---------
208
208
209
209
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ would be run (implies --chatty))
95
95
96
96
$(DT $(B --eval)=code) $(DD evaluate code including it in
97
97
---
98
- void main(char[] [] args) { ... }
98
+ void main(string [] args) { ... }
99
99
---
100
100
(multiple --eval allowed, will be
101
101
evaluated in turn))
Original file line number Diff line number Diff line change @@ -1014,7 +1014,7 @@ new Foo;
1014
1014
------
1015
1015
class Foo
1016
1016
{
1017
- this(char[] a) { ... }
1017
+ this(string a) { ... }
1018
1018
1019
1019
new(uint size, int x, int y)
1020
1020
{
Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ $(DD Explains the return value of the function.
335
335
* Returns: The contents of the file.
336
336
*/
337
337
338
- void[] readFile(char[] filename) { ... }
338
+ void[] readFile(const( char) [] filename) { ... }
339
339
------------------------------------
340
340
341
341
$(DT $(B See$(UNDERSCORE)Also:))
@@ -364,7 +364,7 @@ $(DD Lists exceptions thrown and under what circumstances they are thrown.)
364
364
* Throws: WriteException on failure.
365
365
*/
366
366
367
- void writeFile(char[] filename) { ... }
367
+ void writeFile(string filename) { ... }
368
368
------------------------------------
369
369
370
370
$(DT $(B Version:))
Original file line number Diff line number Diff line change 93
93
94
94
$(P The solution is to use exception handling to report errors. All
95
95
errors 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 )
97
97
with a human readable description of the error.)
98
98
99
99
$(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):
496
496
$(P An associative array can be tested to see if an element is in the array:)
497
497
498
498
-------------
499
- int foo[char[] ];
499
+ int foo[string ];
500
500
...
501
501
if ("hello" in foo)
502
502
...
@@ -2092,7 +2092,7 @@ import std.stdio, std.typecons;
2092
2092
void main()
2093
2093
{
2094
2094
alias Tup = Tuple!(int, string);
2095
- alias AA = long[char[] ];
2095
+ alias AA = long[string ];
2096
2096
2097
2097
static if (is(Tup : Template!Args, alias Template, Args...))
2098
2098
{
@@ -2102,10 +2102,10 @@ void main()
2102
2102
writeln(typeid(Args[1])); // immutable(char)[]
2103
2103
}
2104
2104
2105
- static if (is(AA T : T[U], U : const char[] ))
2105
+ static if (is(AA T : T[U], U : string ))
2106
2106
{
2107
2107
writeln(typeid(T)); // long
2108
- writeln(typeid(U)); // const char[]
2108
+ writeln(typeid(U)); // string
2109
2109
}
2110
2110
2111
2111
static if (is(AA A : A[B], B : int))
You can’t perform that action at this time.
0 commit comments