Examples Wanted: Usages of "body" as a Symbol Name

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 5 11:08:50 PDT 2016


On Wednesday, 5 October 2016 at 17:17:32 UTC, default0 wrote:
> 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 at 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.

I know that Walter is against contextual keywords.  We had a long 
discussion on this about attributes like nogc.  I made a wiki 
trying to explain the reasoning behind it:

http://wiki.dlang.org/Language_Designs_Explained#Why_don.27t_we_create_a_special_rule_in_the_syntax_to_handle_non-keyword_function_attributes_without_an_.27.40.27_character.3F

In my opinion, having to write "body_" instead of "body" is a 
minor annoyance, but just minor.  I'm not sold that contextual 
keywords are bad, but if they are, then this "keyword" problem is 
hard to solve, and the current solution isn't so bad. Also, 
there's alot of other important things to be done with D, I don't 
think this one is very high on the list.



More information about the Digitalmars-d mailing list