if(arr) now a warning

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri May 1 12:45:36 PDT 2015


On 5/1/2015 12:06 PM, deadalnix wrote:
> On Friday, 1 May 2015 at 18:45:54 UTC, Walter Bright wrote:
>> On 5/1/2015 11:09 AM, deadalnix wrote:
>>> neither you nor walter provide a good sum up of your discussion.
>>
>> My last post here: https://github.com/D-Programming-Language/dmd/pull/2885
>
> So, the plan is to make this a warning ? If so that sound like the right way
> forward.

You must be looking at something else. What I said, and I quote:
-------------------
I'll try to summarize:
1.this should have been better specified to begin with
2.there are incorrect usages of  if (arr)  in the wild
3.there are correct usages of  if (arr)  in the wild

The case  if (arr) ...arr[0]...  will produce a runtime error, so I am not 
terribly concerned that is a disastrous problem.

What does greatly concern me is this change will break a LOT of long standing, 
correct D code. This is a long standing complaint about D, and has driven away a 
lot of users. There are also the users driven way because they download existing 
D code, and that code doesn't compile. They don't really care why it doesn't 
compile, just that it doesn't compile, and they don't look any further.

Is  if(arr)  a problem big enough to merit taking this rather large risk? I'm 
skeptical. I suspect this kind of change and check would be appropriate for a D 
linter, and not be part of the core language.
----------------------


More information about the Digitalmars-d mailing list