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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Nov 26 08:24:49 PST 2013


On 11/26/13 1:22 AM, bearophile wrote:
> Andrei has written elsewhere in this thread:
>> As I wrote in TDPL, it's a bad idea to add a global somewhere and
>> break a bunch of code that has nothing to do with it.<
>
> Global (or module-level in D, often thread-local) variables are
> sometimes useful, but a D programmer should minimize their number. If
> you add a global variable, and the compiler gives you several name
> shadowing errors elsewhere, you choose a different name for the global
> variable, you don't break the code. If you add a local variable that
> shadows a global variable and you receive a shadowing error, you choose
> a different name for the local variable. This avoid using the "g_" prefix.

The problem is "you" who added the global and "you" whose code is broken 
may be in fact two different people.

It's safe to end this discussion. Doing absolutely nothing has a lot 
going for it in this case.


Thanks,

Andrei



More information about the Digitalmars-d mailing list