www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5775] New: "body" keyword is unnecessary

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: alvaro.segura gmail.com



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: -------
Mar 23 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5775


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Considering the strong resistance against adding new kewords to D, in D there
are several unused keywords, like "typedef", "macro", "body", "delete", "cent",
"ucent"...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5775


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PDT ---
cent and ucent _should_ be kept around. They're _supposed_ to be unused
keywords at this point. The idea is that if/when we need to add 128 bit
integers to the language, we already have keywords for them. That way, we'll be
able to add them without breaking code.

macro should likely be kept in case we actually do something with AST macros
(or some other macro-like mechanism) in a future version of the language.

We may or may not care about keeping typedef once the construct that it's
currently used has been removed. We could probably remove it. The same goes for
delete.

body... Well, I tend to agree that one is totally unnecessary. It probably
simplifies the parsing a bit, but unless it's needed to keep the grammar
context-free (which it might be, depending on what the exact grammar is for in,
out, and body blocks - though I doubt it), it should be able to be removed.
However, since it's in the language and its use hasn't changed at all over time
(as far as I know), Waler at least thought that we should have it, and unless
something about the situation or his opinion has changed in the interim, I
doubt that he'll want to get rid of it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5775


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |WONTFIX



19:00:36 PST ---
{ ... } { ... } just looks wrong. Hence the body keyword.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2012