DMD can implicitly convert class pointer to the bool. Is it bug or terrible feature?
Craig Dillabaugh
craig.dillabaugh at gmail.com
Sun Nov 24 20:27:19 PST 2013
On Monday, 25 November 2013 at 03:12:03 UTC, Andrei Alexandrescu
wrote:
> On 11/24/13 6:48 PM, ilya-stromberg wrote:
>> On Sunday, 24 November 2013 at 23:31:38 UTC, Andrei
>> Alexandrescu wrote:
>>> On 11/24/13 11:17 AM, bearophile wrote:
>>>> Walter Bright:
>>>>
>>>>> Shadowing globals is definitely a bad idea. Shadowing
>>>>> members, it's
>>>>> debatable.
>>>>
>>>> So are you saying D here should give an error for the
>>>> shadowing of the
>>>> module-level x?
>>>
>>> I think he meant "shadowing locals". 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.
>>
>> Yes, but D allows to use it. And in few cases global variable
>> can be
>> useful.
>> For example, we can have thread-local variable for database
>> connection
>> that used almost everywhere.
>
> I agree. What I'm saying is it's not good to make shadowing a
> global an error. It puts the onus in the wrong place.
>
> Andrei
Would it be possible to introduce a global scope of sorts that
had to be explicitly referenced when one wanted to define or use
a global variable. I haven't thought of how this might interface
with other D features, but something along the lines of:
@global int my_gobal_var; //Gets added to global scope.
//Then any globals would have to be referenced as:
global.my_global_var = 7;
Makes for a bit of extra typing, and would mess with any module
named 'global', but it might work?
More information about the Digitalmars-d
mailing list