January 28, 2014
On Tuesday, 28 January 2014 at 12:58:29 UTC, Stanislav Blinov wrote:
> On Tuesday, 28 January 2014 at 12:57:02 UTC, Andrej Mitrovic wrote:
>
>> "body" is probably the most frequent issue I run into when porting
>> C/C++ code to D.
>>
>> I really wonder whether the rule could be relaxed a little bit.
>
> o_O How?

Not being a keyword except in places where it is used as such.
January 28, 2014
On Tuesday, 28 January 2014 at 22:35:31 UTC, Martin Cejp wrote:

>>> I really wonder whether the rule could be relaxed a little bit.
>>
>> o_O How?
>
> Not being a keyword except in places where it is used as such.

Only if it's not a keyword at all, lest you complicate parsing. You wouldn't want any other keyword (I dunno, int?) get a special treatment now, would you?

Don't get me wrong, I'm all for allowing to use "body" as an identifier in user code, I just don't see any half-measures in that regard :)
January 29, 2014
On 1/28/14, 3:17 PM, Chris wrote:
> On Tuesday, 28 January 2014 at 17:18:44 UTC, Ary Borenszweig wrote:
>> On 1/28/14, 11:30 AM, bearophile wrote:
>>> Ary Borenszweig:
>>>
>>>> In Ruby you can do this:
>>>>
>>>> class Foo
>>>>  def end
>>>>    1
>>>>  end
>>>> end
>>>>
>>>> Foo.new.end
>>>
>>> Ruby is a different language from D, they define "code safety" in quite
>>> different ways.
>>>
>>> Bye,
>>> bearophile
>>
>> Having a method named "end" doesn't make the language less safe.
>
> End is cumbersome and looks awkward. Sure there are other ways ;)

Yes, as there are other ways for body: _body, _body, Body, HtmlBody, etc. But "body" is the best one.
January 29, 2014
On Wednesday, 29 January 2014 at 17:11:32 UTC, Ary Borenszweig wrote:

> Yes, as there are other ways for body: _body, _body, Body, HtmlBody, etc. But "body" is the best one.

torso? ;)
January 30, 2014
On Wednesday, 29 January 2014 at 17:12:57 UTC, Stanislav Blinov wrote:
> On Wednesday, 29 January 2014 at 17:11:32 UTC, Ary Borenszweig wrote:
>
>> Yes, as there are other ways for body: _body, _body, Body, HtmlBody, etc. But "body" is the best one.
>
> torso? ;)

offspring = document.createElement("div");

document.torso.addOffspring(div);
January 30, 2014
On Thursday, 30 January 2014 at 10:15:10 UTC, Chris wrote:

> offspring = document.createElement("div");
>
> document.torso.addOffspring(div);

Looks great! :D
February 01, 2014
On Tuesday, 28 January 2014 at 22:50:27 UTC, Stanislav Blinov wrote:
> On Tuesday, 28 January 2014 at 22:35:31 UTC, Martin Cejp wrote:
>
>>>> I really wonder whether the rule could be relaxed a little bit.
>>>
>>> o_O How?
>>
>> Not being a keyword except in places where it is used as such.
>
> Only if it's not a keyword at all, lest you complicate parsing. You wouldn't want any other keyword (I dunno, int?) get a special treatment now, would you?
>
> Don't get me wrong, I'm all for allowing to use "body" as an identifier in user code, I just don't see any half-measures in that regard :)

It's surprisingly easy to implement, see here:
https://github.com/schuetzm/dmd/commit/955be4ef9f26e92f7a0d5dedf86b64a03d903be8

It requires only a few trivial changes to the compiler, but I have
to admit that it makes the code uglier. In particular, it doesn't
scale; every keyword treated in this way requires additional
special handling.

I'm not sure whether I should make a PR from this...
1 2 3
Next ›   Last »