Jump to page: 1 26  
Page
Thread overview
"body" keyword is unnecessary
Mar 23, 2011
Alvaro
Mar 23, 2011
Trass3r
Mar 24, 2011
Bekenn
Mar 25, 2011
Ary Manzana
Mar 24, 2011
Sönke Ludwig
Mar 24, 2011
Nick Sabalausky
Mar 24, 2011
Andrej Mitrovic
Mar 24, 2011
Jonathan M Davis
Mar 24, 2011
Andrej Mitrovic
Mar 24, 2011
piotrek
Mar 24, 2011
sclytrack
Mar 24, 2011
bearophile
Mar 24, 2011
KennyTM~
Mar 24, 2011
piotrek
Mar 24, 2011
Don
Mar 24, 2011
piotrek
Mar 25, 2011
Don
Mar 25, 2011
piotrek
Mar 25, 2011
Walter Bright
Mar 25, 2011
bearophile
Mar 26, 2011
Alvaro
Mar 26, 2011
bearophile
Mar 25, 2011
Walter Bright
Mar 24, 2011
KennyTM~
Mar 24, 2011
piotrek
Mar 25, 2011
Bekenn
Mar 24, 2011
Jonathan M Davis
Mar 24, 2011
Jonathan M Davis
Mar 25, 2011
Andrej Mitrovic
Mar 28, 2011
Walter Bright
Mar 28, 2011
Jonathan M Davis
Mar 28, 2011
Walter Bright
Jul 28, 2013
Vlad
Nov 18, 2017
Eljay
Nov 18, 2017
bauss
Nov 18, 2017
Meta
Nov 19, 2017
Tony
Nov 19, 2017
Seb
Nov 19, 2017
Tony
Nov 19, 2017
Tony
Nov 19, 2017
bauss
Nov 19, 2017
Tony
Nov 21, 2017
Nick Treleaven
Nov 19, 2017
Tony
Nov 19, 2017
Basile B.
Nov 19, 2017
Meta
Nov 19, 2017
Jonathan M Davis
Nov 19, 2017
Meta
Nov 19, 2017
Meta
Nov 19, 2017
Basile B.
"body" can be a symbol and "do" has another use
Nov 27, 2017
Ali Çehreli
March 23, 2011
D already has a long list of keywords, reserved words can't be used as identifiers, which can be annoying. "body" in particular is a common noun that programmers would gladly use as a 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. What is different in the body itself of a function with and without contracts to make one body{...} and the other {...}?

Example:

int myfunc(int x)
in{
    ...contract preconditions...
}
out (result){
    ...contract postconditions...
}
body{
    ...code...
}

But we don't write:

int myfunc(int x)
body{
    ...code...
}

The body keyword can be omitted and still interpret the code correctly given this 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:

int myfunc(int x)
in{
    ...contract preconditions...
}
out (result){
    ...contract postconditions...
}
{
    ...code...
}

and be perfectly understandable, with the benefit of one less keyword. The compiler, upon reading the opening "{" after the out block, would know it is the beginning of the function body.

Or I am missing something that would overcomplicate parsing, etc?

Best regards

March 23, 2011
Yep, this has been brought up at least once before.
Nothing has happened so far.
March 24, 2011
Interestingly, you don't even have to remove "body" from the syntax to remove it as a keyword, as it's only used in this context (that I know of), where no other symbols make sense.
March 24, 2011
I'm all for this change.

Since there are already similar differences between 1.0 and 2.0 (e.g. invariant()) and projects can be fixed by a more or less simple search and replace, this would be a cheap way to clean up a keyword that can truly get in your way (in contrast to some others that have already been removed).

Actually I think the only keywords that really got in my way were "body" and "function" - I now have modules named body_.d and function_.d
March 24, 2011
On Wed, 23 Mar 2011 23:17:32 +0100, Alvaro wrote:

> D already has a long list of keywords, reserved words can't be used as identifiers, which can be annoying. "body" in particular is a common noun that programmers would gladly use as a 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.

yes, please

body is also a html tag

Cheers
Piotrek
March 24, 2011
== Quote from piotrek (starpit@tlen.pl)'s article
> On Wed, 23 Mar 2011 23:17:32 +0100, Alvaro wrote:
> > D already has a long list of keywords, reserved words can't be used as identifiers, which can be annoying. "body" in particular is a common noun that programmers would gladly use as a 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.
> yes, please
> body is also a html tag
> Cheers
> Piotrek

Copied the following line from the Vala (=mostly reference counted language) web page.

"It is possible to use a reserved keyword as identifier name by prefixing it with the @ character. This character is not part of the name. For example, you can name a method foreach by writing @foreach, even though this is a reserved Vala keyword."

My body is hungry and starving.


March 24, 2011
sclytrack:

> Copied the following line from the Vala (=mostly reference counted language) web page.
> 
> "It is possible to use a reserved keyword as identifier name by prefixing it with the @ character. This character is not part of the name. For example, you can name a method foreach by writing @foreach, even though this is a reserved Vala keyword."

In C# there is the same thing:

>The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.<

http://msdn.microsoft.com/en-us/library/aa664670%28v=vs.71%29.aspx

Bye,
bearophile
March 24, 2011
On Mar 24, 11 19:00, sclytrack wrote:
> == Quote from piotrek (starpit@tlen.pl)'s article
>> On Wed, 23 Mar 2011 23:17:32 +0100, Alvaro wrote:
>>> D already has a long list of keywords, reserved words can't be used as
>>> identifiers, which can be annoying. "body" in particular is a common
>>> noun that programmers would gladly use as a 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.
>> yes, please
>> body is also a html tag
>> Cheers
>> Piotrek
>
> Copied the following line from the Vala (=mostly reference counted language) web page.
>
> "It is possible to use a reserved keyword as identifier name by prefixing it with
> the @ character. This character is not part of the name. For example, you can name
> a method foreach by writing @foreach, even though this is a reserved Vala keyword."
>
> My body is hungry and starving.
>
>

How is this better than _body or body_?
March 24, 2011
On Thu, 24 Mar 2011 21:37:12 +0800, KennyTM~ wrote:

> On Mar 24, 11 19:00, sclytrack wrote:
>> == Quote from piotrek (starpit@tlen.pl)'s article
>>> On Wed, 23 Mar 2011 23:17:32 +0100, Alvaro wrote:
>>>> D already has a long list of keywords, reserved words can't be used as identifiers, which can be annoying. "body" in particular is a common noun that programmers would gladly use as a 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.
>>> yes, please
>>> body is also a html tag
>>> Cheers
>>> Piotrek
>>
>> Copied the following line from the Vala (=mostly reference counted
>> language) web page.
>>
>> "It is possible to use a reserved keyword as identifier name by prefixing it with the @ character. This character is not part of the name. For example, you can name a method foreach by writing @foreach, even though this is a reserved Vala keyword."
>>
>> My body is hungry and starving.
>>
>>
>>
> How is this better than _body or body_?

I think "@" is a little bit nicer, but it doesn't change the situation at all . body (if possible) shouldn't be a keyword.
Can anyone from the steering group state his opinion? :)

Cheers,
Piotrek
March 24, 2011
piotrek wrote:
> On Thu, 24 Mar 2011 21:37:12 +0800, KennyTM~ wrote:
> 
>> On Mar 24, 11 19:00, sclytrack wrote:
>>> == Quote from piotrek (starpit@tlen.pl)'s article
>>>> On Wed, 23 Mar 2011 23:17:32 +0100, Alvaro wrote:
>>>>> D already has a long list of keywords, reserved words can't be used
>>>>> as identifiers, which can be annoying. "body" in particular is a
>>>>> common noun that programmers would gladly use as a 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.
>>>> yes, please
>>>> body is also a html tag
>>>> Cheers
>>>> Piotrek
>>> Copied the following line from the Vala (=mostly reference counted
>>> language) web page.
>>>
>>> "It is possible to use a reserved keyword as identifier name by
>>> prefixing it with the @ character. This character is not part of the
>>> name. For example, you can name a method foreach by writing @foreach,
>>> even though this is a reserved Vala keyword."
>>>
>>> My body is hungry and starving.
>>>
>>>
>>>
>> How is this better than _body or body_?
> 
> I think "@" is a little bit nicer, but it doesn't change the situation at all . body (if possible) shouldn't be a keyword.
> Can anyone from the steering group state his opinion? :)

What's the steering group?
I raised this exact topic before, with the title "my body is ugly" <g>.
It's a very silly keyword. It's just a comment, really /*body*/.

« First   ‹ Prev
1 2 3 4 5 6