Thread overview | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 05, 2016 Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
I'm currently writing up a DIP to propose removing `body` as a keyword to allow it to be used for variable names, functions, etc. I'm looking for examples and contexts where `body` would normally be used as a variable, function name, alias, etc. This is what I have come up with off the top of my head: - In web programming where "body" is a required tag in any valid HTML document. Ex: - It is a name commonly used for XML tags and/or attributes - Physics simulations as well in astronomical contexts ("planetary bodyies", etc.) - Video games, such as referring to the player character's body |
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
> I'm currently writing up a DIP to propose removing `body` as a keyword to allow it to be used for variable names, functions, etc. I'm looking for examples and contexts where `body` would normally be used as a variable, function name, alias, etc. This is what I have come up with off the top of my head:
>
> - In web programming where "body" is a required tag in any valid HTML document. Ex:
> - It is a name commonly used for XML tags and/or attributes
> - Physics simulations as well in astronomical contexts ("planetary bodyies", etc.)
> - Video games, such as referring to the player character's body
i think you covered most of the cases. as for me, it is more than enough. as for my cases, physics engines suffers most: it is *so* natural to use "body" field/variable there... and so annoying to always add ugly "_" suffix.
|
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | Am 05.10.2016 um 05:04 schrieb ketmar:
> On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
>> I'm currently writing up a DIP to propose removing `body` as a keyword
>> to allow it to be used for variable names, functions, etc. I'm looking
>> for examples and contexts where `body` would normally be used as a
>> variable, function name, alias, etc. This is what I have come up with
>> off the top of my head:
>>
>> - In web programming where "body" is a required tag in any valid HTML
>> document. Ex:
>> - It is a name commonly used for XML tags and/or attributes
>> - Physics simulations as well in astronomical contexts ("planetary
>> bodyies", etc.)
>> - Video games, such as referring to the player character's body
>
> i think you covered most of the cases. as for me, it is more than
> enough. as for my cases, physics engines suffers most: it is *so*
> natural to use "body" field/variable there... and so annoying to always
> add ugly "_" suffix.
+1 to physics, but I also hit it frequently when writing compilers/parsers (function, loop bodies etc.) and other programming language related libraries (scripting interfaces/wrappers).
|
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On 2016-10-05 04:11, Meta wrote: > - In web programming where "body" is a required tag in any valid HTML > document. Ex: > - It is a name commonly used for XML tags and/or attributes > - Physics simulations as well in astronomical contexts ("planetary > bodyies", etc.) > - Video games, such as referring to the player character's body - D compiler implementing the "body" keyword ;) -- /Jacob Carlborg |
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote: > I'm currently writing up a DIP to propose removing `body` as a keyword to allow it to be used for variable names, functions, etc. I'm looking for examples and contexts where `body` would normally be used as a variable, function name, alias, etc. This is what I have come up with off the top of my head: > > - In web programming where "body" is a required tag in any valid HTML document. Ex: > - It is a name commonly used for XML tags and/or attributes > - Physics simulations as well in astronomical contexts ("planetary bodyies", etc.) > - Video games, such as referring to the player character's body Physics libraries absolutely. https://github.com/d-gamedev-team/dchip/blob/55f43e5f0cf67c8bc190711b69eb16230fa6188e/src/dchip/cpBody.d#L184 https://github.com/d-gamedev-team/dbox/blob/6f81fe065abec1e7def44fc777c5d8e9da936104/examples/demo/tests/bodytypes.d#L103 And in various C / C++ libraries. It's rather annoying that body is taken, it's a fairly rarely used keyword in D but often used in other languages. |
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On Wednesday, 5 October 2016 at 12:02:21 UTC, Andrej Mitrovic wrote: > On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote: >> [...] > > Physics libraries absolutely. > > https://github.com/d-gamedev-team/dchip/blob/55f43e5f0cf67c8bc190711b69eb16230fa6188e/src/dchip/cpBody.d#L184 > https://github.com/d-gamedev-team/dbox/blob/6f81fe065abec1e7def44fc777c5d8e9da936104/examples/demo/tests/bodytypes.d#L103 > > And in various C / C++ libraries. It's rather annoying that body is taken, it's a fairly rarely used keyword in D but often used in other languages. I created D bindings for chipmunk (unlike dchip which reimplemented it in D) and I had to change a _lot_ of bodies: https://github.com/rcorre/chipmunkd/commit/d6bde5b649c70a53f4295f522e660fae3c1e740f |
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
> I'm currently writing up a DIP to propose removing `body` as a keyword to allow it to be used for variable names, functions, etc. I'm looking for examples and contexts where `body` would normally be used as a variable, function name, alias, etc. This is what I have come up with off the top of my head:
>
> - In web programming where "body" is a required tag in any valid HTML document. Ex:
> - It is a name commonly used for XML tags and/or attributes
> - Physics simulations as well in astronomical contexts ("planetary bodyies", etc.)
> - Video games, such as referring to the player character's body
Really, why do we need a _body_ ?
We have pre-condition and post-condition (in and out), everything else is a body.
It is simply inconsistent - a regular function with no in and out blocks has no body block. Now one adds a pre-condition (and / or post-condition) - whoop - one needs to wrap the whole function body ... well in a body expression.
|
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to angel Attachments:
| On Wed, Oct 5, 2016 at 5:32 PM, angel via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
> On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
>
>> I'm currently writing up a DIP to propose removing `body` as a keyword to allow it to be used for variable names, functions, etc. I'm looking for examples and contexts where `body` would normally be used as a variable, function name, alias, etc. This is what I have come up with off the top of my head:
>>
>> - In web programming where "body" is a required tag in any valid HTML
>> document. Ex:
>> - It is a name commonly used for XML tags and/or attributes
>> - Physics simulations as well in astronomical contexts ("planetary
>> bodyies", etc.)
>> - Video games, such as referring to the player character's body
>>
>
>
> Really, why do we need a _body_ ?
> We have pre-condition and post-condition (in and out), everything else is
> a body.
> It is simply inconsistent - a regular function with no in and out blocks
> has no body block. Now one adds a pre-condition (and / or post-condition) -
> whoop - one needs to wrap the whole function body ... well in a body
> expression.
>
Recently I've had to use scope_ a lot more often than body_ but reserved keywords are really annoying, so the less we have the better :D
|
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rory McGuire | On Wednesday, 5 October 2016 at 16:57:42 UTC, Rory McGuire wrote:
> On Wed, Oct 5, 2016 at 5:32 PM, angel via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>
>> On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
>> [...]
>> Really, why do we need a _body_ ?
>> We have pre-condition and post-condition (in and out), everything else is
>> a body.
>> It is simply inconsistent - a regular function with no in and out blocks
>> has no body block. Now one adds a pre-condition (and / or post-condition) -
>> whoop - one needs to wrap the whole function body ... well in a body
>> expression.
>>
>
> Recently I've had to use scope_ a lot more often than body_ but reserved keywords are really annoying, so the less we have the better :D
Agreed - I have exactly the same problem with "version", which is also really common for, well, to hold a version number of a component. Body is annoying too.
But, can keywords actually sanely be removed from the language without breaking the world?
|
October 05, 2016 Re: Examples Wanted: Usages of "body" as a Symbol Name | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Klumpp | On Wednesday, 5 October 2016 at 17:14:04 UTC, Matthias Klumpp wrote:
> On Wednesday, 5 October 2016 at 16:57:42 UTC, Rory McGuire wrote:
>> On Wed, Oct 5, 2016 at 5:32 PM, angel via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>>
>>> On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
>>> [...]
>>> Really, why do we need a _body_ ?
>>> We have pre-condition and post-condition (in and out), everything else is
>>> a body.
>>> It is simply inconsistent - a regular function with no in and out blocks
>>> has no body block. Now one adds a pre-condition (and / or post-condition) -
>>> whoop - one needs to wrap the whole function body ... well in a body
>>> expression.
>>>
>>
>> Recently I've had to use scope_ a lot more often than body_ but reserved keywords are really annoying, so the less we have the better :D
>
> Agreed - I have exactly the same problem with "version", which is also really common for, well, to hold a version number of a component. Body is annoying too.
>
> But, can keywords actually sanely be removed from the language without breaking the world?
To answer the question: if you can make them contextual keywords instead of keywords, then yes. Naturally that will increase complexity for correct syntax highlighting and similar things one may want to do to D code.
|
Copyright © 1999-2021 by the D Language Foundation