DMD can implicitly convert class pointer to the bool. Is it bug or terrible feature?

ilya-stromberg ilya-stromberg-2009 at yandex.ru
Tue Nov 26 09:39:28 PST 2013


On Tuesday, 26 November 2013 at 17:11:38 UTC, Andrei Alexandrescu 
wrote:
> On 11/26/13 8:52 AM, ilya-stromberg wrote:
>> On Tuesday, 26 November 2013 at 16:27:27 UTC, Andrei 
>> Alexandrescu wrote:
>>> The win of (2) itself is yet to be quantified and the 
>>> breakage is large.
>>
>> Excuse me, did you mean "disable shadowing global variables" 
>> or "disable
>> shadowing class members"?
>
> The latter.

Thanks for explanation.
I was confused because number (2) is "disable shadowing global 
variables" and you wrote that don't want to have it. Thank you 
for explanation because I can't interpret your opinion as I want.

>> If I understand everything correctly, Walter said that 
>> "Shadowing
>> members, it's debatable". His main objection was about 
>> initializing
>> variables in constructor, but we can add syntax sugar for this 
>> case.
>>
>> See also:
>> http://forum.dlang.org/post/l6tg7n$2i7s$1@digitalmars.com
>> http://forum.dlang.org/post/l6tjdq$2kvc$1@digitalmars.com
>> http://d.puremagic.com/issues/show_bug.cgi?id=9801
>
> I think Walter agrees that we can't disallow shadowing globals. 
> Adding additional sugar is pretty much the kiss of death for 
> the entire notion of disallowing shadowing of members.

Excuse me, I didn't understand you.
The main idea:
1) disable shadowing class members
2) add additional syntax sugar for initializing variables in 
constructor as was suggested in #9801

It looks like that solves problem. Is it impossible?

As alternative solution, we can allow shadowing members only for 
function parameters or, maybe, only for constructor. Walter 
agreed that it's possible, "but at the cost of D becoming more of 
a mass of special cases that nobody can remember".
http://forum.dlang.org/post/l6tjdq$2kvc$1@digitalmars.com

So, syntax sugar in #9801 looks like better solution.


More information about the Digitalmars-d mailing list