[Issue 5775] New: "body" keyword is unnecessary
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 23 14:50:15 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5775
Summary: "body" keyword is unnecessary
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: alvaro.segura at gmail.com
--- Comment #0 from Alvaro <alvaro.segura at gmail.com> 2011-03-23 14:46:55 PDT ---
D already has a long list of keywords, and those reserved words can't be used
as identifiers. "body" in particular is a common noun that programmers would
gladly use as variable name in physics simulation, astronomy, mechanics, games,
health, etc. I think "body" can be removed from D with no harm, and with the
benefit of allowing the name as identifier.
Rationale: Functions in C and derived languages have always had a body and they
never needed a keyword. In D, "body" is used to mark the actual body of a
function after the optional "in" and/or "out" contract blocks. From the
documentation:
in{
...contract preconditions...
}
out (result){
...contract postconditions...
}
body{
...code...
}
But the body keyword can be omitted and still interpret the code correctly
given the rule: "An unnamed {} block right after an in{} or out{} block when
defining a function, MUST be the function's body".
Thus, the above code would become:
in{
...contract preconditions...
}
out (result){
...contract postconditions...
}
{
...code...
}
and be perfectly understandable, with the benefit of one less keyword.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list