Skip to content

Commit 335b16a

Browse files
committed
Add 'body' to the list of deprecated features
RIP, you won't be missed. Support for dlang/dmd#10693
1 parent d253fa8 commit 335b16a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

deprecate.dd

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ $(SPEC_S Deprecated Features,
1010

1111
$(TABLE2 Deprecated Features,
1212
$(THEAD Feature, Spec, Dep, Error, Gone)
13+
$(TROW $(DEPLINK body keyword), 2.075, 2.091,  ,  )
1314
$(TROW $(DEPLINK Hexstring literals), 2.079, 2.079, 2.086,  )
1415
$(TROW $(DEPLINK Class allocators and deallocators),  , 2.080, 2.087,  )
1516
$(TROW $(DEPLINK Implicit comparison of different enums), 2.075, 2.075, 2.081,  )
@@ -60,6 +61,38 @@ $(SPEC_S Deprecated Features,
6061
$(DD The feature is completely gone)
6162
)
6263

64+
$(H3 $(DEPNAME body keyword))
65+
$(P 'body' was a keyword used to specify a function/method's body in the presence of contracts
66+
---
67+
class Foo
68+
{
69+
void bar(int i)
70+
in { assert(i >= 42); }
71+
body { /* Do something interesting */ }
72+
73+
string method(string s)
74+
out(v) { assert(v.length == s.length); }
75+
body { /* Do something even more interesting */ }
76+
77+
void noBody() { /* No contracts, no body */ }
78+
}
79+
---
80+
)
81+
$(H4 Corrective Action)
82+
$(P Use the 'do' keyword instead (introduced v2.075.0)
83+
---
84+
void bar(int i)
85+
in { assert(i >= 42); }
86+
do { /* Look ma, no body! */ }
87+
---
88+
)
89+
$(H4 Rationale)
90+
$(P The 'body' keyword was only used for this single purpose.
91+
Since D grammar aims to be context free, this common word was reserved,
92+
which led to frequent trouble for people interfacing with other languages
93+
(e.g. javascript) or auto-generating code.
94+
)
95+
6396
$(H3 $(DEPNAME Hexstring literals))
6497
$(P Hexstring literals can be used to enter literals in base 16.
6598
---

0 commit comments

Comments
 (0)