Skip to content

Commit bccafd8

Browse files
committed
add body legacy code
1 parent 1549905 commit bccafd8

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

deprecate.dd

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -100,44 +100,6 @@ $(H4 Rationale)
100100
would break the guarantees of the $(D nothrow) attribute.
101101
)
102102

103-
$(H3 $(DEPNAME body keyword))
104-
$(P 'body' was a keyword used to specify a function/method's body in the presence of contracts
105-
---
106-
class Foo
107-
{
108-
void bar(int i)
109-
in { assert(i >= 42); }
110-
body { /* Do something interesting */ }
111-
112-
string method(string s)
113-
out(v) { assert(v.length == s.length); }
114-
body { /* Do something even more interesting */ }
115-
116-
void noBody() { /* No contracts, no body */ }
117-
}
118-
---
119-
)
120-
$(H4 Corrective Action)
121-
$(P Use the 'do' keyword instead (introduced v2.075.0)
122-
---
123-
void bar(int i)
124-
in { assert(i >= 42); }
125-
do { /* Look ma, no body! */ }
126-
---
127-
)
128-
$(H4 Rationale)
129-
$(P The 'body' keyword was only used for this single purpose.
130-
Since D grammar aims to be context free, this common word was reserved,
131-
which led to frequent trouble for people interfacing with other languages
132-
(e.g. javascript) or auto-generating code.
133-
)
134-
$(P Note that given the large amount of code relying on the 'body' keyword
135-
(essentially any code using contracts), and the fact that the benefit
136-
of DIP1003 to the user are mostly the ability to use 'body' as an identifier,
137-
the deprecation has been postponed beyond its original goal of 2.091.0.
138-
Users are still encouraged to use 'do' for future-proofness.
139-
)
140-
141103
$(H3 $(DEPNAME Hexstring literals))
142104
$(P Hexstring literals can be used to enter literals in base 16.
143105
---

spec/legacy.dd

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,48 @@ $(HEADERNAV_TOC)
1313

1414
)
1515

16+
$(TABLE2 Legacy Features,
17+
$(THEAD Feature)
18+
$(TROW $(DEPLINK body keyword), usage of identifier $(TT body) as a keyword is obsolete use $(TT do) instead)
19+
)
20+
21+
$(H3 $(DEPNAME body keyword))
22+
$(P `body` was a keyword used to specify a function/method's body in the presence of contracts
23+
---
24+
class Foo
25+
{
26+
void bar(int i)
27+
in { assert(i >= 42); }
28+
body { /* Do something interesting */ }
29+
30+
string method(string s)
31+
out(v) { assert(v.length == s.length); }
32+
body { /* Do something even more interesting */ }
33+
34+
void noBody() { /* No contracts, no body */ }
35+
}
36+
---
37+
)
38+
$(H4 Corrective Action)
39+
$(P Use the `do` keyword instead (introduced v2.075.0)
40+
---
41+
void bar(int i)
42+
in { assert(i >= 42); }
43+
do { /* Look ma, no body! */ }
44+
---
45+
)
46+
$(H4 Rationale)
47+
$(P The `body` keyword was only used for this single purpose.
48+
Since D grammar aims to be context free, this common word was reserved,
49+
which led to frequent trouble for people interfacing with other languages
50+
(e.g. javascript) or auto-generating code.
51+
)
52+
53+
1654
Macros:
1755
CHAPTER=45
1856
TITLE=Legacy Code
57+
DEPLINK=$(RELATIVE_LINK2 $0, $0)
58+
DEPLINK2=$(LINK2 $1.html#$2, $2)
59+
DEPNAME=$(LNAME2 $0, $0)
1960
D=<span class="d_inlinecode">$0</span>

0 commit comments

Comments
 (0)